我创建了一个按钮和代码来锁定(或保护)工作簿中的工作表。我还创建了一个按钮和代码来解锁(或取消保护)工作簿中的工作表。
我有一些列,我希望用户能够输入信息;但我不希望整个工作表解锁/不受保护。
在我的训练表上的例子,单元格K6:U3175我希望不受保护。这是我尝试过的:
'This is for the Lock Button on the WOOKBOOK TIPS sheet.
'Upon clicking once on the LOCK button, the scripts below re-protecting all the worksheets.
ActiveWorkbook.Protect Password:="password"
Sheets("1 - TRAINING").Protect "password"
ActiveSheet.Range("1 - TRAINING").Range("K6:U3175").Locked = False我在解锁范围的代码中得到了错误。如何才能仅取消对该单元格范围的保护?
发布于 2020-09-22 01:48:39
按以下顺序排列:
在cells
的任何单元格或组上,取消保护工作表的锁定/解锁设置
发布于 2020-09-22 02:11:31
您将希望遵循Gary的答案提供的事件顺序。在代码中,这将如下所示
With ThisWorkbook.Worksheet(1)
.Unprotect "1234" 'insert your pasword here (1)
.Range("A:B").Cells.Locked = False '(2)
.Protect "1234" 'insert your pasword here (3)
End Withhttps://stackoverflow.com/questions/63997144
复制相似问题