PDA

View Full Version : help in unhiding all hidden cells and worksheets



dafeizhu
03-29-2007, 02:03 AM
Hi all,

I am a beginner in Macro, so any help is appreciated. I need to write a program to unhide all hidden sheets and cells.

Sub Macro1()

Range("1:20").EntireRow.Hidden = False

Application.Dialogs(xlDialogWorkbookUnhide).Show

End Sub

This is what I can come out with. However, when i execute this, a dialog box will ask me which sheet to unhide. Is there anyway to modify this to save the hassle of unhiding the sheets one by one?

And is there anyway to unhide all cells instead of manually typing the range of the rows? Thks in advance.

Bob Phillips
03-29-2007, 02:11 AM
For Each sh In Activeworkbook.Sheets
sh.Visible = xlSheetVisible
Next sh




Rows.Hidden = False

mdmackillop
03-29-2007, 02:14 AM
Hi,
Welcome to VBAX

Sub ShowAll()
Dim sh As Worksheet
For Each sh In Worksheets
sh.Visible = True
sh.Cells.EntireRow.Hidden = False
sh.Cells.EntireColumn.Hidden = False
Next
End Sub

dafeizhu
03-29-2007, 02:23 AM
thks alot xld and mdmackillop!!!The advice came really fast. This is all I need. Thks again.

Brandtrock
03-29-2007, 02:36 AM
Hi,
Welcome to VBAX

Sub ShowAll()
Dim sh As Worksheet
For Each sh In Worksheets
sh.Visible = True
sh.Cells.EntireRow.Hidden = False
sh.Cells.EntireColumn.Hidden = False
Next
End Sub

Isn't this redundant?
sh.Cells.EntireRow.Hidden = False
sh.Cells.EntireColumn.Hidden = False
Just wondering,

geekgirlau
03-29-2007, 02:50 AM
The original requirement was to display all hidden sheets and cells ...

Brandtrock
03-29-2007, 03:50 AM
Isn't this redundant?
sh.Cells.EntireRow.Hidden = False
sh.Cells.EntireColumn.Hidden = False
Just wondering,
My original reading of the code was that going through the cells collection and unhiding any row with a hidden cell would in effect unhide all of the cells.

This was wrong of course, as you must either hide an entire row, or an entire column to hide an individual cell. If you hide cell C4 by hiding the entire column, running only the rows line leaves Column C hidden. If you hide cell C4 by hiding the entire row, running only the column line leaves Row 4 hidden.

Both are needed, my apologies.

Perhaps I should get some sleep now.

Regards,

geekgirlau
03-29-2007, 05:26 PM
Hey, even Mentors need their beauty sleep :sleeping: