I want to lock certain cells so users of the woorkbook wont be able to make changes but at the same time I want macros to be able to make changes.

For instance I want to lock range "A1" so no user can type things in A1. But the following macro should be able to write and overwrtite in cell A1

Sub Macro1()
a = Date
Range("A1") = a
End Sub