Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I am trying to make a pivot table and my codes are following: Sub PivotTable() Dim pt As PivotTable Dim PRange As Range Dim PTCache As PivotCache Dim FinalRow As Long 'Dim FinalCol As Long Set WSD = Worksheets("Data") Set OutputPivot = Worksheets("Output") FinalRow = WSD.Cells(1048576, 1).End(xlUp).Row Set PRange = WSD.Cells(2, 1).Resize(FinalRow - 1, 19) Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _ SourceData:=PRange) Set pt = PTCache.CreatePivotTable (tabledestination:=ResultsOutputPivot.Range("A1"), _ Tablename:="OutputPT") pt.AddFields RowFields:="Year", ColumnFields:="Name", PageFields:="Regin" pt.AddDataField pt.PivotFields("Production"), "Sum of Production", xlSum End Sub These codes work for a small dataset. However, when I use them to run a larger dataset, at "Set PTCache = ActiveWorkbook.PivotCaches.Add (SourceType:=xlDatabase, SourceData:=PRange)", there is message: Run-time error '13': Type mismatch Any suggestion is appreciated Thank you in advance Fei |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how to create pivot table from existing pivot table in excel 2007 | Excel Discussion (Misc queries) | |||
Filter lines with Pivot table and non pivot table columns | Charts and Charting in Excel | |||
Filter lines with Pivot table and non Pivot table columns | Excel Discussion (Misc queries) | |||
How do I create a pivot table if the pivot table icon or menu ite. | 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 |