Don Fardie
New Member
- Joined
- Aug 6, 2014
- Messages
- 23
I have the VBA coded onto sheet1 of my workbook to clear contents, but as soon as I protect the sheet I get run errors. Have seen posts where you add Unprotect and Protect with your code in between them, but it's not working. I can get it to run without the Run Error pop up, but cells do not clear as they do when the sheet has no protection.
This is the code I have and not sure what the fix is!....Thanks in advance
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("C16:C34")) Is Nothing Then
Range("I" & Target.Row & ":S" & Target.Row).ClearContents
End If
Application.EnableEvents = True
Application.EnableEvents = False
If Not Intersect(Target, Range("C38:C56")) Is Nothing Then
Range("D" & Target.Row & ":P" & Target.Row).ClearContents
End If
Application.EnableEvents = True
End Sub
This is the code I have and not sure what the fix is!....Thanks in advance
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("C16:C34")) Is Nothing Then
Range("I" & Target.Row & ":S" & Target.Row).ClearContents
End If
Application.EnableEvents = True
Application.EnableEvents = False
If Not Intersect(Target, Range("C38:C56")) Is Nothing Then
Range("D" & Target.Row & ":P" & Target.Row).ClearContents
End If
Application.EnableEvents = True
End Sub