Group cells without the totals (conditional grouping)

Migaspt

New Member
Joined
Mar 12, 2014
Messages
22
Hello!

I'm trying to write the code to run a macro on VB to group rows until the totals.


Example:

TITLE 1TITLE 2TITLE 3TITLE 4%
XX1X1198
XX2X2187
XX3X3120
XX1X1210
XX3X32
X TOTAL53.75
YY1Y1168
YY1Y1298
YY2Y2114
Y TOTAL58.44
Grand Total56.35

<tbody>
</tbody>

What I need is to group the Xs and Ys until the totals. The code should stop the groupings when there is the "Grand Total" in column A.
-Some groups can have only one cell to group.
-Grouping should start at the 14th row

(Another way to write it could be to group until the blank cells in column B?)


Can you help me with this?

Thank you very much in advance!:)
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
This is what I need:

ABCDE
1TITLE 1 TITLE 2TITLE 3TITLE 4%
2XX1X1198
3XX2X2187
4XX3X3120
5XX1X1210
6XX3X32
7X TOTAL53.75
8YY1Y1168
9YY1Y1298
10YY2Y2114
11Y TOTAL58.44
12
13Grand Total56.35

<colgroup><col><col span="5"></colgroup><tbody>
</tbody>


Rows to group: 2-6; 8-10; 12
 
Upvote 0
but that is what you have to start with or do you mean eliminate total and g total rows from display
 
Upvote 0
do you want row2 to row6 then 8 to 10 then 12 in a new table with no headers

1....2
4....5
*****
5....7
12...13
15....16
******
27....29

you want

1....2
4.....5
12....13
15....16
 
Upvote 0
What I want is to group rows but leave the total out of the group.

Is it possible to write code for conditional grouping?
Like, group rows if next row's A cell does not have total on the text?

I do not want to delete the rows with total. I want to group the rows that do not have "total" written on their A cell :)

"do you want row2 to row6 then 8 to 10 then 12 in a new table with no headers": No I only need to group the rows on this table. I do not need to create a new table.

I need to do this manually, group rows until the "X Total" row (group the data). The "total" rows are in a different colour aswell. I'll try to upload the actual table for better understanding
 
Last edited:
Upvote 0
Here is the table I start with:

HR GL Dept Org Tree Lvl 6HR GL Dept Org Tree Lvl 7HR Dept Manager Name L1HR Dept Manager Name L2HR Dept Manager Name L3Current SupervisorAvg Utilization % - Week
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)X0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)X0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)X0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)X0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)X0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)X0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)X0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)X
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)X
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)X0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)X0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y50.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y75.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y0.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Y85.0%
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Z
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Z
BELGIUM_ADMINBELG_ADM_OTHER(blank)0(blank)Z0.0%
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z0.0%
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)Z
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)T98.0%
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)T0.0%
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)T0.0%
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)T
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)T
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)T0.0%
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)T0.0%
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)T100.0%
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)T0.0%
BELGIUM_ADMINBELG_GLOB_FUNCT(blank)0(blank)T0.0%
BELGIUM_ADMIN Total 15.1%
BELGIUM_SICPRACTICES_T2(blank)0(blank)T
BELGIUM_SICPRACTICES_T2(blank)0(blank)T0.0%
BELGIUM_SIC Total 0.0%
Grand Total 7.6%

<colgroup><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
I am sorry but it is no clearer to me. What do you mean by group. Do you want a summary table with how many of each group there are. Read my post 6 again and answer my question please. I am not being critical. It is hard for somebody very familiar with a topic to describe an issue to somebody who knows nothing about it.
 
Upvote 0
I am sorry but it is no clearer to me. What do you mean by group. Do you want a summary table with how many of each group there are. Read my post 6 again and answer my question please. I am not being critical. It is hard for somebody very familiar with a topic to describe an issue to somebody who knows nothing about it.

I'm sorry, maybe I'm not explaining myself so good.

What I mean by group rows is the function on Excel when you clik the "Data" tab and then "Group" (It has the "Ungroup" and "Subtotal" buttons on the right)
 
Upvote 0

Forum statistics

Threads
1,214,632
Messages
6,120,655
Members
448,975
Latest member
sweeberry

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