Probably doing something really obvious wrong, but all I want to do is clear the contents of all unlocked cells in a worksheet when the worksheet is activated
here is the code I have which is giving me an error
Where am I going wrong?
here is the code I have which is giving me an error
Code:
Private Sub Worksheet_Activate()
Sheets("Sheet1").Unprotect "password"
Dim r As Range
Set r = Sheets("Sheet1").Range("E3:K25")
For Each Cell In r
If Cell.Locked = False Then
Cell.ClearContents
End If
Next
Sheets("Sheet1").Protect "password"
End Sub
Where am I going wrong?