我需要当用户从下拉菜单中选择一个选项时,它会触发事件并锁定特定范围的单元格。我获得了锁定单元的代码,但是当我选择下拉菜单时无法将其锁定。下拉菜单中字符串数据的值为ZFB50
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$K$2" Then
With Application
.EnableEvents = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
If Target.Address = "ZFB50" Then
ActiveSheet.Unprotect
Range("E8:E100").Select
Selection.Locked = True
Range("C8:C100").Select
Selection.Locked = True
Range("D8:D100").Select
Selection.Locked = True
Range("F8:F100").Select
Selection.Locked = True
Next cell
ActiveSheet.Protect
With Application
.EnableEvents = True
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End If
End Sub
还是不行,这段代码有问题吗?