LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Fei Fei is offline
external usenet poster
 
Posts: 5
Default Pivot table

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create pivot table from existing pivot table in excel 2007 Udayraj Dhulekar Excel Discussion (Misc queries) 2 July 8th 13 08:22 PM
Filter lines with Pivot table and non pivot table columns Grover Charts and Charting in Excel 4 September 28th 07 03:16 AM
Filter lines with Pivot table and non Pivot table columns Grover Excel Discussion (Misc queries) 1 September 26th 07 12:48 AM
How do I create a pivot table if the pivot table icon or menu ite. Lynn@WS Charts and Charting in Excel 1 December 16th 04 02:36 AM
Help required with setting up a pivot table with the source on sheet1 to have the pivot table created on sheet called "report" Diana[_5_] Excel Programming 0 August 21st 03 10:19 PM


All times are GMT +1. The time now is 09:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"