VBA Vlookup & Pivot Table (Get Sum)

unknownymous

Board Regular
Joined
Sep 19, 2017
Messages
249
Office Version
  1. 2016
Platform
  1. Windows
Hi Team,

I have this data with 100K lines and badly need to get a macro as I do this over and over again.

This is the scenario:

"Master" tab - Main Data Sheet
"Reference" tab - Country reference sheet

1.) In the "Master" tab, what I need to do is add a blank column where the macro looks up the COUNTRY and get its equivalent GROUP on "Reference" tab (col B).
The headers can be found on A2-AN2. Country tab can be found in column AE.


This is what Reference Sheet looks like:

CountryGroup
FranceFrance
United KingdomUK & Ireland
IrelandUK & Ireland
CanadaNorth America
NorwayROE
ChileROW

<tbody>
</tbody>


2.) Once the Country Group is ready, I need to pivot that section together with Columns F2:I2 and K2:W2 (where I need to get the sum up to the last non-blank column and the number format is xx,xxx). Next, rename the pivot tab as "PivotedData".


Any help will be much appreciated. :)
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Replace the entire GETPIVOTDATA function and arguments with the cell reference to the cell concerned, and then copy down. e.g. <code style="margin: 0px; padding: 1px 5px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; background-color: rgb(239, 240, 241); white-space: pre-wrap;">=VLOOKUP(E2,SSSContribution[#All],3,TRUE) </code>Note that you can turn off the automatic generation of the GETPIVOTDATA syntax by unchecking this option:

Facebook Marketing
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,648
Members
449,325
Latest member
Hardey6ix

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