我得到的错误“的细胞或聊天你试图改变是在一个受保护的工作表。要进行更改,取消保护工作表”,但我给输入框获取密码从用户这样,自动细胞将被解锁,但为什么我得到这个错误
Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Range
Dim Pass As String
Pass = "Kals"
Set X = Union(Range("I3:I9"), Range("K3:K9"))
If Not Application.Intersect(Target, X) Is Nothing Then
ActiveSheet.Unprotect Password:=LCase(Pass)
If Target = "" Then
ElseIf Target <> "" Then
Pass = InputBox("Enter value", "Enter password")
Target.Locked = True
ActiveSheet.Protect Password:=LCase(Pass)
End If
End If
End Sub
1条答案
按热度按时间5jdjgkvh1#