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....
[TABLE="width: 500"]
<tbody>[TR]
[TD]Models[/TD]
[TD]Drivers[/TD]
[TD]Owned[/TD]
[/TR]
[TR]
[TD]Chevy[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Amy[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Mike[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Jim[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]Ford[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Chris[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Amy[/TD]
[TD]5[/TD]
[/TR]
</tbody>[/TABLE]
I want to select the Drivers columns based on what model I currently am looking at... here is my code so far...
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
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....
[TABLE="width: 500"]
<tbody>[TR]
[TD]Models[/TD]
[TD]Drivers[/TD]
[TD]Owned[/TD]
[/TR]
[TR]
[TD]Chevy[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Amy[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Mike[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Jim[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]Ford[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Chris[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Amy[/TD]
[TD]5[/TD]
[/TR]
</tbody>[/TABLE]
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