ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protecting certain cells (https://www.excelbanter.com/excel-programming/324709-protecting-certain-cells.html)

William Spence

Protecting certain cells
 
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.


KL

Protecting certain cells
 
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


"William Spence" wrote in message
ups.com...
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.





All times are GMT +1. The time now is 08:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com