hiding all groups in a workbook

xcdave

Board Regular
Joined
Nov 11, 2004
Messages
61
I am using the following code to go through my workbook and collapse all the groups:

Sub HideRowsColumns()

Dim i As Integer

For i = 1 To Sheets.Count

Sheets(i).Outline.ShowLevels RowLevels:=1
Sheets(i).Outline.ShowLevels ColumnLevels:=1

Next i

End Sub

The problem is that if my workbook contains sheets that are graphs, the code doesn't work.

What can I add to the code so that it skips any sheets that are graphs?

Thanks!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Untested but try this.
Code:
Sub HideRowsColumns()

Dim ws As Worksheet

For Each ws In Worksheets
     ws.Outline.ShowLevels RowLevels:=1
     ws.Outline.ShowLevels ColumnLevels:=1
Next ws

End Sub
 
Upvote 0
That works, but it takes over a minute to run the macro. I turned screen updating off, and it still took over 1 min. Any other ideas?
 
Upvote 0

Forum statistics

Threads
1,216,485
Messages
6,130,938
Members
449,608
Latest member
jacobmudombe

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