I have a spreadsheet which has a column on it (say column A). The idea is this column is populated by a user with various scores. Once the user is happy with their answers in column A, I want them to confirm that the answers are correct (ideally by clicking a button). Once that button is clicked, I want to use VBA to protect column A against being edited again. I’d rather not use the protect worksheet option, as there is additional data in the spreadsheet where I need to keep some cells locked but editable (they use data validation lists).
I did find this bit of VBA but this is based on worksheet change – if I could somehow use this but only have it activate once the user has confirmed the data is set, that would be ideal:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Target, Range("A2:A14")) Is Nothing Then Exit Sub
Application.EnableEvents = False
MsgBox "Hey, leave me alone!", 48, "Sorry, I'm protected."
Application.Undo
Application.EnableEvents = True
End Sub
If what you posted suits your needs then:
In a module, something like this:
And within your spreadsheet code:
A likely better solution would be to designate a cell within your sheet that the button populates, so the code would actually be something like: