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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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.
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,220
Members
448,554
Latest member
Gleisner2

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