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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,300
Office Version
  1. 365
Platform
  1. Windows
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
 

xcdave

Board Regular
Joined
Nov 11, 2004
Messages
61
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?
 

Forum statistics

Threads
1,136,990
Messages
5,678,979
Members
419,796
Latest member
doctorgresham

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
Top