Protecting certain cells

  • Thread starter Thread starter William Spence
  • Start date Start date
W

William Spence

I am writing a program where i need to clear, and color certain cells,
but want the user to have read only access on this particular page.
When i all the cells i want locked and I protect the sheet, my program
keeps getting stopped on the lines of code that clears, and colors
these cells. How would i keep these cells protected but still be able
to clear and color them.
 
Hi William,

You can just unprotect and protect the sheet within your macro, e.g.:

Sub Test()
Pass="YourPassword"
Worksheets("Sheet1").Unprotect Pass
'your code here
Worksheets("Sheet1").Protect Pass
End Sub

Regards,
KL
 

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