J
Jcraig713
In my spreadsheet, I have a clear button (coded below). The whole
sheet (all cells) are locked except range E5 - E12 , G3 and G5
through G12 which are unlocked.
What I want to do upon click of the clear button is for the the
cells in E5-E12 & G3 to be cleared leaving the unprotected cell
range G5 through G12 uncleared then of course leaving all other
locked cells alone. What can I add or change in my code to
accomplish this?
Private Sub ClearButton1_Click()
Dim cell As Range
Range("E5:E12", "G3").Select
For Each cell In Selection
If cell.Locked = False Then
cell.ClearContents
End If
Range("G3").Select
Range("G3").Activate
Next
End Sub
sheet (all cells) are locked except range E5 - E12 , G3 and G5
through G12 which are unlocked.
What I want to do upon click of the clear button is for the the
cells in E5-E12 & G3 to be cleared leaving the unprotected cell
range G5 through G12 uncleared then of course leaving all other
locked cells alone. What can I add or change in my code to
accomplish this?
Private Sub ClearButton1_Click()
Dim cell As Range
Range("E5:E12", "G3").Select
For Each cell In Selection
If cell.Locked = False Then
cell.ClearContents
End If
Range("G3").Select
Range("G3").Activate
Next
End Sub