VBA Multiple Selections in Pivot Tables

Littlemalky

Board Regular
Joined
Jan 14, 2011
Messages
223
So I'm creating a pivot table in vba trying to use the report filter. However, I haven't been able to figure out how to make selections within that filter. If i did it manually, there is a button to check for multiple selections, in which I deselect everything, and select only those that begin with the word "Polar". So I'm trying to figure out how to use it with a wild card because there are many variations that come with "Polar", but that's the static part of the selection. This is my code thus far, and if anyone knows how to make it more efficient, I'm all ears because I'm new to this stuff:
Code:
Private Sub TestPivot()
    Sheets.Add.Name = "PivotTest"
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=Worksheets("ATP").Range("A1").CurrentRegion, Version:=xlPivotTableVersion12).CreatePivotTable _
        TableDestination:="PivotTest!R1C1", TableName:="PivotTest"
    With ActiveSheet.PivotTables("PivotTest").PivotFields("Component")
        .Orientation = xlRowField
        .Position = 1
    End With
    With ActiveSheet.PivotTables("PivotTest").PivotFields("Component-Description")
        .Orientation = xlRowField
        .Position = 2
    End With
    With ActiveSheet.PivotTables("PivotTest").PivotFields("FG Req")
        .Orientation = xlDataField
        .Function = xlSum
    End With
    With ActiveSheet.PivotTables("PivotTest").PivotFields("Polar")
        .Orientation = xlPageField
    End With
    With ActiveSheet.PivotTables("PivotTest")
       .InGridDropZones = True
        .RowAxisLayout xlTabularRow
    End With
    ActiveSheet.PivotTables("PivotTest").PivotFields("Component").Subtotals = _
        Array(False, False, False, False, False, False, False, False, False, False, False, False)
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

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