Pivot Table: How to code a Special grouping using VBA

hcova

New Member
Joined
Jul 29, 2010
Messages
19
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Dear sirs:
I have the following pivot table:

Row LabelsSum of Q2017Sum of Q2018Diff_Q%Share
East52654639-62638%
Boston22901994-29647%
Philadelphia1045879-16627%
New York18111709-10216%
Miami11957-6210%
West1620612-100862%
Seattle43755-38238%
Portland444107-33733%
Las Vegas23782-15515%
San Diego422338-848%
San Francisco8030-505%
Total general68855251-1634100%

<tbody>
</tbody>

I need to code in VBA a macro that allow me to group the cities according the %share column. In the following way:

Row LabelsSum Q2017Sum Q2018 Diff_Q %Share
East52654639-62638%
Boston22901994-29647%
Philadelphia1045879-16627%
Rest19301766-16426%
West1620612-100862%
Seattle43755-38238%
Portland444107-33733%
Rest739450-28929%
Total general68855251-1634100%

<tbody>
</tbody>

As you can see what I need is create a group called for “Rest” that includes (add) all cities whose %share value be under 25%. Moreover each subtotal row must keep the same previous value.
In advance, thanks a lot.
Best regards
Hernan Covarrubias
h.covarru@gmail.com

PS: If anyone needs the worksheet I can send it.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,215,248
Messages
6,123,869
Members
449,130
Latest member
lolasmith

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