excel2003如何设置的列与列单元格的各自保护?
颜晓华吧
全部回复
仅看楼主
level 1
anjw1977 楼主
各位大侠!excel2003如何设置的列与列单元格的各自保护?如:B列是入库数,C列是出库数,B列与C列是二个人各自操作的,如何设置B列的密码与C列的密码?
2010年04月24日 01点04分 1
level 7
在ThisWorkbook 中放入如下代码
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
     Sheets("Sheet1").Select   ' Sheet1 是指你要保护的表名。
     ActiveSheet.Unprotect Password:="123"
     Columns("B:B").Locked = True
     Columns("C:C").Locked = True
     ActiveSheet.Protect Password:="123", DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
在Sheet1 的代码中放入如下代码
Public B_Value As Boolean, C_Value As Boolean
Private Sub Worksheet_Activate()
B_Value = False
C_Value = False
     ActiveSheet.Unprotect Password:="123"
     Columns("B:B").Locked = True
     Columns("C:C").Locked = True
     ActiveSheet.Protect Password:="123", DrawingObjects:=True, Contents:=True, Scenarios:=True
    
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim Temp_key As String
If Target.Column = 2 Then
If B_Value Then
Exit Sub
Else
Temp_key = InputBox("Pls key in the Key!")
If Temp_key = "bbb" Then
B_Value = True
     ActiveSheet.Unprotect Password:="123"
     Columns("B:B").Locked = False
     ActiveSheet.Protect Password:="123", DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
End If
End If
If Target.Column = 3 Then
If C_Value Then
Exit Sub
Else
Temp_key = InputBox("Pls key in the Key!")
If Temp_key = "ccc" Then
C_Value = True
     ActiveSheet.Unprotect Password:="123"
     Columns("C:C").Locked = False
     ActiveSheet.Protect Password:="123", DrawingObjects:=True, Contents:=True, Scenarios:=True
End If
End If
End If
End Sub

2010年04月24日 09点04分 2
level 1
不知如何放到代码
2012年02月16日 12点02分 3
1