I made a macro that deletes data within a cell range in 20 sheets. I did this before I named the sheets so I was having subscript errors as the macro is referring to sheet names that don't exist any more.
I've opted to use the codeName e.g Sheet4
as this should never change (as someone else suggested on another question). However the macro breaks as soon as it hits this part of the code.
Sheet4.Range("TimeSheet4[[Start Time]:[Holiday]]").Select
Selection.ClearContents
Sheet5.Range("TimeSheet45[[Start Time]:[Holiday]]").Select
Selection.ClearContents
Sheet6.Range("TimeSheet456[[Start Time]:[Holiday]]").Select
Selection.ClearContents
Sheet7.Range("TimeSheet4567[[Start Time]:[Holiday]]").Select
Selection.ClearContents
It was done like this previously and worked but I was intending to tidy the code.
Sheets("Employee 2 ").Select
Range("TimeSheet4[[Start Time]:[Holiday]]").Select
Selection.ClearContents
Sheets("Employee 3").Select
Range("TimeSheet45[[Start Time]:[Holiday]]").Select
Selection.ClearContents
Sheets("Employee 4").Select
Range("TimeSheet456[[Start Time]:[Holiday]]").Select
Selection.ClearContents
Sheets("Employee 5").Select
Range("TimeSheet4567[[Start Time]:[Holiday]]").Select
Selection.ClearContents