简体   繁体   English

组列但不保护它们,密码保护组列之一

[英]Group columns but not protect them and password protect one of the group column

I Have 3 columns a,b,c which I want to group and show as grouped( collapsed section). 我有3列a,b,c,我想对其进行分组并显示为分组(折叠部分)。 Column B is locked and when I try to ungroup a,b,c columns it asks me password. B列已锁定,当我尝试取消对a,b,c列的分组时,它询问我密码。 I dont want it to ask the password as only column B is password protected not the grouping ungrouping action. 我不希望它询问密码,因为只有B列受密码保护而不是分组取消分组操作。

How can I solve this problem in excel/vba 如何在Excel / VBA中解决此问题

you can add a piece of code to run at beginning and end of your routine. 您可以添加一段代码在例程的开头和结尾运行。 This will un-protect the sheet, run your code, then protect it again. 这将取消保护工作表,运行您的代码,然后再次保护它。

Begin: 开始:

Dim mypassword As String

mypassword = "yourPassword"

ActiveSheet.Unprotect Password:=mypassword

End: 结束:

ActiveSheet.Protect Password:=mypassword

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

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