![](/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.