Reputation: 59
I installed a very simple command button to timestamp a selected cell. The command button works completely fine until I protect the sheet, then it throws the error mentioned in the title. I have already checked that the cells' format is not selected to 'locked'.
Private Sub CommandButton1_Click()
Dim ts As Date
With Selection
.Value = Now
.NumberFormat = "h:mm AM/PM"
End With
End Sub
Upvotes: 2
Views: 12098
Reputation: 54883
You have to allow Formatting of cells.
or in VBA
ActiveSheet.Protect AllowFormattingCells:=True
Upvotes: 4