Macro which ungroups columns

wotonka

Board Regular
Joined
Aug 6, 2002
Messages
142
I have 3 sets of groups. Each group consolidates 4 columns. Is there a macro which would selectively ungroup each of the grouped columns, and a separate macro which would re-group them? I have tried recording the macro, but this must be one of the non-recordable functions. I have also searched the message board, but no luck. Thanks for your help.

P.S. Are there good references which would describe each of the commands within the object model, giving examples (similar to the help feature for functions).

Thanks very much in advance for any help you can offer!
Guy
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Try something alond these lines:
Code:
Sub Hide()
    Range("A:D").EntireColumn.Hidden = True
    Application.Goto Reference:=[A1]
End Sub

Sub UnHide()
    Range("A:D").EntireColumn.Hidden = False
    Application.Goto Reference:=[A1]
End Sub

Sub UnHide1()
' To unhide everything at once, use:
    Cells.EntireColumn.Hidden = False
    Application.Goto Reference:=[A1]
End Sub
And it is a recordable action.

Hope that helps,

Smitty

EDIT:
P.S. Are there good references which would describe each of the commands within the object model, giving examples (similar to the help feature for functions).

In VBA, goto View-->Object Browser.
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,456
Hi wotonka, (greetings Smitty!),
If you need to only deal with one group at a time, I think you'll have to limit yourself to hiding / unhiding as Smitty suggests. If you can live with expanding / contracting all groups at a time, you can use this.
Code:
Sub ContractGroup()
ActiveSheet.Outline.ShowLevels RowLevels:=1
End Sub
and this:
Code:
Sub ExpandGroup()
ActiveSheet.Outline.ShowLevels RowLevels:=2
End Sub

This help?
Dan
 

wotonka

Board Regular
Joined
Aug 6, 2002
Messages
142
The suggestions offered by Smitty and Half Ace worked great! As you can tell, I am a newbie VBA writer. Thanks for helping out!!!

Guy
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Anytime! Glad we could help!

(Heya Ace! - Got one for ya' - "PETA - People Eating Tasty Animals!", as an old rancher I can say that! :devilish: )

Smitty
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,456
Ha,ha
I was actually going to change my quote to say "P.E.T.A. - People Eating The Animals" Near as I can tell, if you're hungry enough any animal would qualify as tasty! :unsure: (Now I'll have to come up with somethng else.)

Hope all is going well,
Dan
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,151,871
Messages
5,766,855
Members
425,380
Latest member
CubeGirl

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