Unlock cell by VBA

  • Thread starter Thread starter Roscoe
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top