简体   繁体   中英

How to make the excel sheet protected and unprotected by using Excel VBA macro?

All I wrote an excel VBA macro code, to do some math and presentation, but the macro does not work well, because the sheet is password protected, so I need a VBA code, to be included in my macro, to make the sheet unprotected, then do the math and presentation, then return the sheet protected again with the same password . We can assume the password is “hello”

Use:

Sheet1.UnProtect Password:="YOUR_PASSWORD"

and

Sheet1.Protect Password:="YOUR_PASSWORD"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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