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