Posted on 28 June 2009
How to create a pivot table using VBA? Assuming that the data for the pivot table is laid out like this, then all you need to
create a pivot using vba are there four lines of code:
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= ActiveSheet.UsedRange).CreatePivotTable TableDestination:="", TableName:= "PivotTable1", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(1, 1)
ActiveSheet.PivotTables("PivotTable1").AddFields RowFields:="Name"
ActiveSheet.PivotTables("PivotTable1").PivotFields("Name").Orientation = xlDataField
The pivot table so created using the VBA code above can be ...
Continue Reading
Posted on 07 November 2008
Reading pivot tables using vba can be quite easy. Here are a few ways you can do it.
You may also want to read my previous article on
formatting pivots.
(Before you dive further, you may want to download this
example which will guide you through some of the steps in reading a pivot table data using vba)
The Pivot Table Hierarchy
Lets look at this peice of code:
Sub ListAllItemObjects()...
Continue Reading