Hi,
I'm trying very hard to Delete a range on all worksheets but 1.
I have a code that protects all sheets and I'm trying to edit it to delete a range on all worksheets but 1. I've changed the "if" line to read:
If objSheet.Sheet2.Name = True Then objSheet.Cells.Range("a1:j9").ClearContents
Where am I going wrong? Or should I being going a different way.
Thanks
Working code
"Public Sub aProtectAllSheets()
Dim objSheet As Worksheet
'Protecting all worksheets with password
For Each objSheet In Worksheets
If objSheet.ProtectContents = False Then objSheet.Protect "abc"
Next objSheet
End Sub"
I'm trying very hard to Delete a range on all worksheets but 1.
I have a code that protects all sheets and I'm trying to edit it to delete a range on all worksheets but 1. I've changed the "if" line to read:
If objSheet.Sheet2.Name = True Then objSheet.Cells.Range("a1:j9").ClearContents
Where am I going wrong? Or should I being going a different way.
Thanks
Working code
"Public Sub aProtectAllSheets()
Dim objSheet As Worksheet
'Protecting all worksheets with password
For Each objSheet In Worksheets
If objSheet.ProtectContents = False Then objSheet.Protect "abc"
Next objSheet
End Sub"