Using a marco to expand ALL grouped cells

stephenpilcher

New Member
Joined
Jan 22, 2009
Messages
9
Hello,

I was hoping someone may be able to help me with a query. I have a spreadsheet which involves lots of grouped rows so that information can be hidden or displayed as the user decides. I would like to recorda macro that expands or contracts ALL the grouped rows. I tried to record one but in the VB code it does not record me expanding the groups. Any ideas if there is a way around this?

Thank you in advance for your help.

Best Regards,

Steve
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Thanks very much for this. It worked a treat!

Do you happen to know howI could use a similar code to then contract the rows. I tried changing your idea from 'ShowLevels' to 'HideLevels' but it did not work.

Any ideas would be appreciated...

Steve
 
Upvote 0
Well, you could just call the Outline property with the Outline level set as 1:

Code:
Sheets("YourSheet").Outline.ShowLevels 1

If you have multiple levels and you want them all collapsed then I think you may have to loop thru the lot of them:

Code:
For i = 8 to 1 Step -1
  Sheets("YourSheet").Outline.ShowLevels i
Next i
 
Upvote 0
Is there a way to expand, for example, only 2 of 5 groupings on multiple sheets? I have a workbook of about 30 sheets, with identically formatted data on each sheet (the numbers change from sheet to sheet, but not the row or column headings). Depending on how I how/to whom I want to present the data, I want 2 of my groupings expanded or collapsed. And I want this change to occur on every sheet, consistently, without having to click on each sheet, and then expand 2 groupings (lots of clicks).

Your macro appears to expand all groupings on a sheet - I only want to expand 2 of the groupings on a sheet.

I'm not sure if your macro will work on more than one sheet at once? Would you just change the code to list all worksheets? How might that look?
 
Upvote 0

Forum statistics

Threads
1,223,176
Messages
6,170,544
Members
452,336
Latest member
boekl007

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