So I have very basic code that says unhide all hidden worksheets and what I want to do next is select 4 of those specific worksheets and delete contents starting in rows 1:5000 and then bring me back to the "Shipped" worksheet in cell A1.
Below is my code but the code stops at the red bolded text line below and I get an error that says run-time error '1004': select methoid of sheets class failed
Public Sub Unhide()
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In ActiveWorkbook.Sheets
sh.Visible = xlSheetVisible
Sheets(Array("Shipped", "Shipped_Balls", "Open", "Open_Balls")).Select
Sheets("Shipped").Activate
Rows("1:5000").Select
Selection.ClearContents
Sheets("Shipped").Activate
Range("A1").Select
Next
Application.ScreenUpdating = True
Sheets("Order_Pace_Summary").Select
Range("BA1").Select
End Sub
When I break up the unhide sheets separate from the clearing contents portion of the code it works fine, but together i get this error
Below is my code but the code stops at the red bolded text line below and I get an error that says run-time error '1004': select methoid of sheets class failed
Public Sub Unhide()
Dim sh As Worksheet
Application.ScreenUpdating = False
For Each sh In ActiveWorkbook.Sheets
sh.Visible = xlSheetVisible
Sheets(Array("Shipped", "Shipped_Balls", "Open", "Open_Balls")).Select
Sheets("Shipped").Activate
Rows("1:5000").Select
Selection.ClearContents
Sheets("Shipped").Activate
Range("A1").Select
Next
Application.ScreenUpdating = True
Sheets("Order_Pace_Summary").Select
Range("BA1").Select
End Sub
When I break up the unhide sheets separate from the clearing contents portion of the code it works fine, but together i get this error
Last edited: