Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pivot table in VB
I have the following code I tried to use to create Pivot table.
Sub CreatePivotTable() Dim PTCache As PivotCache Dim PT As PivotTable Worksheets.Add ActiveSheet.Name = "PivotSheet" Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:=Range("A1").CurrentRegion.Address) Set PT = PTCache.CreatePivotTable(TableDestination:=Sheets( "PivotSheet").Range("A1"), TableName:=" PivotTable") With PT ..PivotFields("Month").Orientation = xlPageField ..PivotFields("Control Number").Orientation = xlColumnField ..PivotFields("Company Code").Orientation = xlRowField ..PivotFields("Tax Payments").Orientation = xlDataField End With End Sub It gives me "error 1004" and highlights the line: Set PT = PTCache.CreatePivotTable(TableDestination:=Sheets( "PivotSheet").Range("A1"), TableName:=" PivotTable") What have I done wrong? |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to create pivot table from existing pivot table in excel 2007 | Excel Discussion (Misc queries) | |||
Pivot Table and Pivot Table dates are not in correct order | Charts and Charting in Excel | |||
Copying values from pivot table to cells outside pivot table | Excel Discussion (Misc queries) | |||
Filter lines with Pivot table and non pivot table columns | Charts and Charting in Excel | |||
Help required with setting up a pivot table with the source on sheet1 to have the pivot table created on sheet called "report" | Excel Programming |