Am having a problem clearing cells in my code, this has been working without any problem for months now, and am unsure what has changed to cause it to stop working.
Anyway here is the code
the error message I get is
"Run-time error '1004':
The cell or chart that you are trying to change is protected and therefore read-only.
To modify a protected cell or chart, first remove protection using the Unprotect Sheet command (Review tab, Changes group). You may be prompted for a password."
Any idea what might be causing this. Or how to find out what cell the error is occuring because of.
Anyway here is the code
Code:
Sheets("Report").Select
Sheets("Report").Unprotect "password"
Sheets("Report").Range("A265:N624").Select
Range("A265:N624").Clear
Range("A265:N624").EntireRow.Hidden = True
Sheets("Report").Protect "password"
For Each cl In Sheets("Report").Range("A1:N264").Cells
If cl.Locked = False Then
If cl.MergeCells = True Then
Set clMerge = Range(cl.Address).MergeArea
clMerge.ClearContents
Else
cl.ClearContents
End If
End If
Next cl
the error message I get is
"Run-time error '1004':
The cell or chart that you are trying to change is protected and therefore read-only.
To modify a protected cell or chart, first remove protection using the Unprotect Sheet command (Review tab, Changes group). You may be prompted for a password."
Any idea what might be causing this. Or how to find out what cell the error is occuring because of.