Protecting Excel sheets using VBA

Abhi86

New member
Joined
Mar 29, 2018
Messages
3
Reaction score
0
Points
0
Location
Mumbai
Excel Version(s)
2007
I am using below mentioned code to protect my sheets through VBA in excel:
sh1.Protect Password:="abcd"
sh2.Protect Password:="efgh"

Once i run the code it locks my sheets and password i require to unprotect them is "abcd" and "efgh" respectively. If i change the password manually by using the protect sheet from review ribbon from say "abcd" and "efgh" to "1234" and "5678" and re run the code, password i require to unprotect the sheets are "1234" and "4567" instead of "abcd" and "efgh". Is there any way by which i can avoid this, as i do not want default password to get overwrite manually.
:frusty::frusty::frusty:
I will be thankful for the solution.
 
Use the code in the sheet change or sheet selectionchange code module.
 
Last edited by a moderator:
I am not having exposure to you suggested method, can you please tell me how to use your information in VBA code
 
Back
Top