How do I collapse multiple columns *that are not in a connecting selection" as a single group?

cluelessintern

New Member
Joined
Aug 19, 2015
Messages
6
I have many columns (budget, forecast, and variance) for each month and quarter. I need to collapse and expand the variance columns as one group. How do I do this?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
if they are not in a "connecting selection" (ex. your variance being in cells A1 B1 C1 D1 E1) you cannot group them. Another solution you can do is create a macro that hides the cells the variance data is in.....simple click of a button can hide them or unhide them
 
Upvote 0
I tried creating a macro to accomplish this. Here are the steps I'm taking (correct me where I go wrong):

1)Record Macro
2)Highlight columns I need hidden (example: Column A, C, & G)
3)Right click, "Hide columns"
4)Stop recording.

I would then go on to create a second macro to unhide those columns, however when I test the first macro, it only hides a single column. How do I get around this? Thanks.
 
Upvote 0
Still no luck.

Here is my code, what do you recommend I do?

Sub mintest1()
'
' mintest1 Macro
'
' Keyboard Shortcut: Ctrl+s
'
Selection.EntireColumn.Hidden = True
End Sub
 
Upvote 0
Ok, one thing i see is there is no range to hide, so try this

Range("B:B,D:D,F:F,H:H,J:J").Select

Put the code above right above the "Selection.EntireColumn.Hidden = True" part in your macro. You will have to replace the "B:B,D:D,F:F,H:H,J:J" with the columns that you want to hide.

So your macro woudl look like this


Sub mintest1()
'
' mintest1 Macro
'
' Keyboard Shortcut: Ctrl+s

Range("B:B,D:D,F:F,H:H,J:J").Select
Selection.EntireColumn.Hidden = True

End Sub


Let me know if it works
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,558
Latest member
aivin

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