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!:)
 
TITLE 1TITLE 2TITLE 3TITLE 4%
XX1X1198O
XX2X2187O
XX3X3120O
XX1X1210O
XX3X32O
X TOTAL53.75
YY1Y1168O
YY1Y1298O
YY2Y2114O
Y TOTAL58.44
Grand Total56.35
the pivot table is in a fixed starting location
in this case cell B2
so we can start pulling data from B3
we do not pull a line if it contains the text "total"
so if B cells are not blank we pull the C,D,E,F cells
########
>>>>>XX1X11098
XX2X21087
XX3X31020
XX1X12010
XX3X3200
YY1Y11068
YY1Y12098
YY2Y21014
formula in cell marked >>>>(b25)
=IF(B3="","",IF(ISERROR(SEARCH("total",B3)),B3,""))
formula in cell marked ####(c25)
=IF(B25="","",C3)

<colgroup><col width="64" span="7" style="width:48pt"> </colgroup><tbody>
</tbody>
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
the syntax is not the same you will need a VBA manual

if it must be VBA it is probably easier to loop through the pivot table printing only lines without total inthe first column
 
Upvote 0

Forum statistics

Threads
1,215,374
Messages
6,124,574
Members
449,173
Latest member
Kon123

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