Group rows on selected sheets

imaguy77

New Member
Joined
Aug 26, 2008
Messages
21
Hi all,

I'm trying to find a macro to do the following:

I select (highlight) a varying number of sheets, and highlight a varying number of rows (for example, select sheets 1 - 10, rows 1-10) and i would like the macro to group those rows on each sheet so they can all be collapsed. Excel by default will not allow you to group with more than 1 sheet selected.

Any help would be greatly appreciated!
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try...

Code:
[font=Verdana][color=darkblue]Option[/color] [color=darkblue]Explicit[/color]

[color=darkblue]Sub[/color] test()

    [color=darkblue]Dim[/color] sh [color=darkblue]As[/color] [color=darkblue]Object[/color]

    [color=darkblue]For[/color] [color=darkblue]Each[/color] sh [color=darkblue]In[/color] ActiveWindow.SelectedSheets
        [color=darkblue]If[/color] TypeName(sh) = "Worksheet" [color=darkblue]Then[/color]
            sh.Range(Selection.Address).Rows.Group
        [color=darkblue]End[/color] [color=darkblue]If[/color]
    [color=darkblue]Next[/color] sh
        
[color=darkblue]End[/color] [color=darkblue]Sub[/color]
[/font]
 
Upvote 0

Forum statistics

Threads
1,215,402
Messages
6,124,708
Members
449,182
Latest member
mrlanc20

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