ThrottleWorks
Excel Ninja
Hi,
I am using below mentioned recorded (and edited) code to populate a Pivot table.
This is working for me now, however can anyone suggest improvements to this code if possible.
I am using below mentioned recorded (and edited) code to populate a Pivot table.
This is working for me now, however can anyone suggest improvements to this code if possible.
Code:
Dim PvtDest1 As Range
Set PvtDes1 = Pvt.Range("b10")
Dim PvtStrg1 As String
PvtStrg1 = "Age Status"
Dim PvtStrg2 As String
PvtStrg2 = "Age Bucket"
Pvt.Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
Rng16, Version:=xlPivotTableVersion14). _
CreatePivotTable TableDestination:=PvtDes1, TableName _
:="PivotTable4", DefaultVersion:=xlPivotTableVersion14
ActiveWorkbook.ShowPivotTableFieldList = True
With ActiveSheet.PivotTables("PivotTable4").PivotFields(PvtStrg1)
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable4").AddDataField ActiveSheet.PivotTables( _
"PivotTable4").PivotFields(PvtStrg2), "Count of Age Bucket", xlCount
With ActiveSheet.PivotTables("PivotTable4").PivotFields("Trade Type")
.Orientation = xlRowField
.Position = 1
End With
ActiveWorkbook.ShowPivotTableFieldList = False