1
votes

I am looking to run a macro which will populate certain cells automatically then lock the information in the cell at the end of the macro so other users cannot edit once populated.

Is there a way to protect/lock a single cell using a macro and without protecting the sheet?

Thank you

1
Not that I know of. I think you need to protect sheet and unlock all other cells.Philip Brack
Hi Philip, Thanks for that!adamsmith

1 Answers

0
votes

In case you want to use the suggestion I had in the comment to make the spreadsheet feel unprotected but not for that single cell of interest.

' set cell range you want to be editable.  I used a random range here
Worksheets("yoursheet").Range("A1:G100").Locked = True
' suppose you want B2 locked
Worksheets("yoursheet").Cells(2,2).Locked = True
' protect the sheet
Worksheets("yoursheet").Protect UserInterfaceOnly:=True, AllowFormattingColumns:=True, AllowFormattingRows:=True