VBA to group rows on multiple tabs

mountainman88

Board Regular
Joined
Jun 22, 2019
Messages
109
Office Version
  1. 2016
Platform
  1. Windows
As far as I can tell you can ctrl-select multiple tabs an d apply row groupings.

Can I get some VBA that will loop through a list of tab names in column A of a tab called 'group'. And then group multiple sets of rows based on a specified start and end row to group on those tabs named?

eg. on 'group' tab cells A1 - A3 contains Cat, mouse, rat

On the tabs called cat, mouse, tab rows will be grouped based on a specified start and end row (in Columns B and C?) for each grouping.

In reality the rows i am grouping on each tab are 12-13, 15-16, 18-19, 26-27 if that makes thins easier.

thanks!
 
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
As far as I can tell you can ctrl-select multiple tabs an d apply row groupings.
Not on Excel 2019 at least - the Group/Ungroup options are greyed-out when you select multiple tabs.

Can I get some VBA that will loop through a list of tab names in column A of a tab called 'group'. And then group multiple sets of rows based on a specified start and end row to group on those tabs named?
Try this macro with a sheet named 'Groups' and this layout:
Group rows.xlsm
AB
1SheetRows to Group
2Sheet112:13,15:16,18:19,26:27
3Sheet212:13,15:16,18:19,26:27
4Sheet312:13,15:16,18:19,26:27
Groups

VBA Code:
Public Sub Group_Rows_on_Sheets()

    Dim r As Long
    Dim rowGroups As Variant, rowGroup As Variant
   
    With Worksheets("Groups")
        For r = 2 To .Cells(.rows.Count, "A").End(xlUp).Row
            rowGroups = Split(.Cells(r, "B").Value, ",")
            For Each rowGroup In rowGroups
                Worksheets(.Cells(r, "A").Value).rows(rowGroup).Group
            Next
        Next
    End With
   
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,815
Messages
6,121,715
Members
449,049
Latest member
THMarana

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