简体   繁体   English

VBA Excel-根据单元格值保护工作表中的列

[英]VBA Excel - Protect column in a sheet based on a cell value

1 1 2 ACT ACT FCST 1 1 2 ACT ACT FCST

I have three columns, I would like to run a loop code to check values in 2nd row if it is ACT or FCST. 我有三列,我想运行一个循环代码来检查第二行中的值是ACT还是FCST。 If it is ACT, it will protect the whole column so it will not be updated. 如果是ACT,它将保护整个列,因此不会被更新。

You don't protect columns, you protect sheet. 您不保护列,而是保护工作表。 Cells are set as locked or not locked. 单元格设置为锁定或未锁定。 Then if the sheet protection is activated, locked cells cannot be edited. 然后,如果激活了纸张保护,则无法编辑锁定的单元格。 So to unlock cells to make them editable, you have to unprotect the sheet, set cells as unlocked then protect the sheet. 因此,要解锁单元格以使其可编辑,您必须取消保护工作表,将单元格设置为未锁定,然后保护工作表。

Use the macro recorder to help you create code. 使用宏记录器可以帮助您创建代码。 When you develop code that has issue, post it for analysis. 开发有问题的代码时,请将其发布以进行分析。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM