Dim pttbl As PivotTable
Sub createPivot()
On Error Resume Next
For Each pttbl In ThisWorkbook.Sheets(2).PivotTables
ThisWorkbook.Sheets(2).Range(pttbl.TableRange2.Address).Delete
Next
ThisWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=ThisWorkbook.Sheets(1).Range("A1").CurrentRegion.Address). _
CreatePivotTable TableDestination:=ThisWorkbook.Sheets(2).Range("C5"), TableName:="PivotTable1"
With ThisWorkbook.Sheets(2).PivotTables("PivotTable1")
.PivotFields("Processed by").Orientation = xlRowField
.PivotFields("status").Orientation = xlDataField
.PivotFields("Transaction type").Orientation = xlPageField
End With
End Sub
https://drive.google.com/file/d/0B23eJ2xd9ODyRFgxWGhhVldGUzQ/edit?usp=sharing
No comments:
Post a Comment