How do I unhide all sheets on the left of Excel

S

Saucer Man

I have a macro that creates many temporary sheets and then deletes them. It
creates so many that my original sheets get hidden on the left of excel.
After the deletes, it doesn't move the sheets that are hidden on the left
back into view. Is there a VBA statement that will accomplish this?
 
J

JLGWhiz

You can run this macro.


Sub due()
For i = 2 To ThisWorkbook.Sheets.Count
If Sheets(i).Visible = False Then
Sheets(i).Visible = True
Next
End Sub
 
S

Saucer Man

That does bring the sheets out but I want the latest sheet to be the one
that is selected. Since the sheets are named Jan, Feb, Mar, etc., would the
best way to do this be ...

Sheets("Jan").Select
Sheets(Month(Now)).Select



Rick Rothstein said:
Give this statement a try...

Worksheets(1).Select
 
R

Rick Rothstein

That is almost right; however, the Month function returns a number, not
text. You should use this for your last statement...

Sheets(MonthName(Month(Now), True)).Select

as that will return the current month's abbreviated name (change True to
False, or leave that argument out completely, and the MonthName function
returns the fully spelled out month name). By the way, you might try just
using this last statement by itself, without the Sheets("Jan") statement,
and see if it brings out all the sheets directly.

--
Rick (MVP - Excel)


Saucer Man said:
That does bring the sheets out but I want the latest sheet to be the one
that is selected. Since the sheets are named Jan, Feb, Mar, etc., would
the best way to do this be ...

Sheets("Jan").Select
Sheets(Month(Now)).Select
 
S

Saucer Man

Thanks a lot. Leaving out the first statement did not bring out the rest of
the sheets. Thanks for the help everyone.
 
Top