Pivot Tables
Create a Pivot Table
Dim PC As PivotCache
Set PC = ThisWorkbook.PivotCaches.Create( _
SourceType:='xlDatabase', 'xlConsolidation', 'xlExternal'
SourceData:='Range'
)
Dim PT As PivotTable
Set PT = PC.CreatePivotTable( _
TableDestination:='Range'
TableName:='TableName'
)
PT.AddFields _
'RowFields', _
'ColumnFields', _
'PageFields' 'NB: if there are multiple items, place in Array('Field', 'Field')
PT.AddDataField PT.PivotFields('FieldName', , 'Function' )