Info

1 Define input area and set up a Pivot Cache FinalRow = WSD.Cells(65536, 1).End(xlUp).Row Set PRange = WSD.Cells(1, 1).Resize(FinalRow, 8)

Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, _

SourceData:=PRange.Address) Set PT = PTCache.CreatePivotTable(TableDestination:=WSD.Range("J2"), _

TableName:="PivotTable1") PT.ManualUpdate = True ' Set up the row & column fields

PT.AddFields RowFields:=Array("Product", "Customer"), ColumnFields:="Region" ' Set up the data fields With PT.PivotFields("Revenue") .Orientation = xlDataField .Function = xlSum .Position = 1 End With

' Calc the pivot table PT.ManualUpdate = False PT.ManualUpdate = True End Sub

0 0

Post a comment