I am very new to VBA coding on Excel, and I have run into a problem, that I'm not sure what I've done wrong.
I have a button designed on a worksheet to clear all the unprotected cells. This is the code:
Sub ClearUnlockedCells()
Dim WorkRange As Range
Dim Cell As Range
Dim intresponse As Integer
Set WorkRange = ActiveSheet.UsedRange
For Each Cell In WorkRange
Next
intresponse = MsgBox("Are you sure you want to Clear this Worksheet?", vbYesNo + vbQuestion, "Quit")
If intresponse = vbNo Then End
If intresponse = vbYes Then
If Cell.Locked = False Then Cell.ClearContents
End If
End Sub
When I try to run this, I get Run-Time Error 91, and the debugging points me back to the "If Cell.Locked = False" part.
Any suggestions would be greatly appreciated.
Bookmarks