VBA to Collapse Groups

Rhys

New Member
Joined
Jun 2, 2004
Messages
15
Hi,

Part of a macro that I have written groups several sets of columns together (with the nice + above the columns!). I recorded this part of the macro, but excel doesnt record my actions when I collapse the groups to hide the grouped columns. Can anybody suggest some VBA?

Thanks in advance...
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try these:

Code:
Sub Collapse()
    Worksheets("Sheet1").Columns("A").ShowDetail = False
End Sub

Sub Expand()
    Worksheets("Sheet1").Columns("A").ShowDetail = True
End Sub

where column A is the first column in your outline. Change the Sheet reference to suit.
 
Upvote 0
Check ShowLevels in XL VBA help. It is used as:

Code:
    Worksheets(3).Outline _
        .ShowLevels rowLevels:=3, columnLevels:=2
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,794
Members
449,468
Latest member
AGreen17

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