Unhide Sheets and clear contents question

cagez0r

New Member
Joined
Jun 24, 2011
Messages
2
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

 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi VoG,

Now that I corrected my initial post with the code...any possible solutions to help me out?
 
Upvote 0
One or more of the sheets is hidden.

I see you have code trying to unhide all sheets..
However, you're trying to select them before they are all unhidden.
The loop unhiding the sheets needs to complete first, then do what you want..

put the Next, before the line selecting the sheets.
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,879
Members
452,948
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top