PivotTable Selection VBA

JST013

Board Regular
Joined
Mar 11, 2015
Messages
74
Hello Mr.Excel board!

Today I am working with pivot tables! I'm trying to get select all values of a secondary rows labels.

so the pivot table looks something like....

ModelsDriversOwned
Chevy
Amy1
Mike4
Jim3
Ford
Chris2
Amy5

<tbody>
</tbody>



I want to select the Drivers columns based on what model I currently am looking at... here is my code so far...
Code:
    With piv8
        .PivotSelect "Model", xlLabelOnly, True
        Set modelrng = Selection
    End With
    For Each guy In modelrng
       Intersect(piv11.PivotFields("Model").PivotItems("" & guy & "").DataRange.EntireRow, _
       piv11.PivotFields("Driver").DataRange).Select
       Set piv11rng = Selection
       With cover
            .Range(.Cells(8, 1), .Cells(17, 1)) = piv11rng.Value
        End With
    Next guy

So, piv8 is a separate pivot table that contains a solid list of my models. Ford, Chevy, Toyota, and Subaru. Piv11 Contains my drivers sorted by model. I am also, at the end of the code, pasting to a cover so I can see what I have selected more easily.

My code is currently only selecting the first driver...I want to be able to select any number of drivers and the end game goal is to copy them and paste them somewhere else if that helps.


Thank you in advance
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,216,075
Messages
6,128,659
Members
449,462
Latest member
Chislobog

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