Your macro can unprotect the sheet, do what you need and protect the
sheet again.
Sub Test()
Sheeets("Sheet1
With Sheets("Sheet1")
.Unprotect Password:="JustMe"
.Range("A1").AddComment ("Merry Christmas")
.Range("B1")="Hello"
.Protect Password:="JustMe"
End With
End Sub
Thanks for the replies. Is there anyway to "allow edit" ONLY a range of
cells? There are other cells I would like to disallow edit. Also, the
macro is performing a "paste special" option to replace a formula. The
cell that contains the formula I would like to protect to keep from
accidental overwrites.
By default all cells on a sheet are locked when you protect the sheet.
Best is to select all cells by CTRL + a and unlock all.
Then select those cells which you want locked and set them to locked.
Now protect the sheet. Users can edit unlocked cells.
See options for allowables when go to Tools>Protect Sheet
If you want to edit a locked cell via macro, you must add code to unprotect,
do the stuff, then re-protect.
Sub pasteit()
Activesheet.unprotect password:="mypassword"
code to do things
Activesheet.protect password:="mypassword"
End Sub
Gord
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.