![](/img/trans.png)
[英]Copying values in excel to another sheet, based on other values in the sheet
[英]Hello, I am trying to lock the cells in an excel sheet based on the values in other sheet of the excel
我尝试了各种代码,这些代码似乎对其他人而言非常有效,但就我而言,并非如此。 在我向工作表编写任何代码之前,工作表中的所有单元格始终显示为“已锁定”。 我被困在这里,不知道可以在这里做什么。
我尝试了这段代码,但似乎什么都没有锁定,我仍然可以做我想做的任何事情。
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1") = "Accepting" Then
Range("B1:B4").Locked = False
ElseIf Range("A1") = "Refusing" Then
Range("B1:B4").Locked = True
End If
End Sub
除非还保护了工作表,否则锁定范围将无效。
例如, Range("B1:B4").Locked = True
在您执行YourWorksheet.Protect
之前不会YourWorksheet.Protect
。 您可以在执行YourWorksheet.Unprotect
之后取消保护它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.