vba pivot table select multiple field values

KJC75

New Member
Joined
Nov 4, 2014
Messages
1
I would like to use vba code to select the field values in the first two columns of my pivot table. For example, if my pivot table is as follows:

COMPANY STATE REVENUE
Nike OR $100
REI WA $50
Columbia OR $25
Grand Total $175

I would like VBA to select the following text.
Nike OR
REI WA
Columbia OR

Here is some code I found online to select one column at a time:

Sheets("Sheet1").Select
Dim Pt As PivotTable
Set Pt = Sheets("Sheet1").PivotTables(1)
Pt.PivotFields("Company").DataRange.Select

I then copy the data to another sheet. I could repeat this for the "State" column, but my real life spreadsheet has a lot more info that I need to copy and paste, so I'd rather copy all the field values at once.

Anyone know how I can select Company and State values at the same time?

Thanks!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,217,382
Messages
6,136,231
Members
450,000
Latest member
jgp19

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