Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Application.DisplayAlerts = False
If Target.Interior.ColorIndex <> 6 Then '6表示黄色
ps = Application.InputBox("请输入密码", "密码核对")
'MsgBox ps
If ps = 123 Then '123是编辑权限密码
ActiveSheet.Unprotect Password:="123"
ElseIf ps <> "" And ps <> 123 And ps <> "False" Then
MsgBox "密码错误"
Cancel = True
ElseIf ps = "" Then
MsgBox "没有输入密码"
Else
Cancel = True
End If
End If
Application.DisplayAlerts = True
End Sub
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Application.DisplayAlerts = False
If Target.Interior.ColorIndex <> 6 Then '6表示黄色
ps = Application.InputBox("请输入密码", "密码核对")
'MsgBox ps
If ps = 123 Then '123是编辑权限密码
ActiveSheet.Unprotect Password:="123"
ElseIf ps <> "" And ps <> 123 And ps <> "False" Then
MsgBox "密码错误"
Cancel = True
ElseIf ps = "" Then
MsgBox "没有输入密码"
Else
Cancel = True
End If
End If
Application.DisplayAlerts = True
End Sub