Unlock cell by VBA

R

Roscoe

I have a cell I don't want folks to touch, but I want to be able to
change it via a macro. I lock the cell and then protect the sheet,
thus locking them out. However, it also locks out my macro. How can I
temporarily unlock the cell long enough to make the change?

Thanks
roscoe
 
O

Otto Moehrbach

Roscoe
Leave that cell locked. Just UnProtect the sheet in your code, do what
you want, then protect the sheet. The code is:
Worksheets("TheShtName").UnProtect Password:="Roscoe"

Worksheets("TheShtName").Protect Password:="Roscoe"

If you are not using a password, just remove the "Password:="Roscoe"

HTH Otto
 
Top