使用超过65536行的Excel 2007文件在VBA中创建数据透视表 [英] Pivot Tables creation in VBA using Excel 2007 file with more than 65536 rows
问题描述
我正在创建一个宏来在Excel 2007中运行报告.excel文件包含超过13479038个单元格(aprox 1035863行和16列)。
我需要创建一个数据透视图我的数据表。 VBA中的代码如下所示:
Dim veryFinalRow As Variant
veryFinalRow = Range(" P1048576")。End(xlUp).Row
Sheets.Add
Sheets("CBW12F.tmp")。选择
'在Sheet1中创建数据透视表
ActiveWorkbook.PivotCaches.Create(SourceType:= xlDatabase,SourceData:= _
表格(CBW12F.tmp)。范围(单元格(1,1),单元格(veryFinalRow,16)),版本:= xlPivotTableVersion12)。 _
CreatePivotTable TableDestination:=" Sheet1!R3C1",TableName:=" PivotTable1" _
,DefaultVersion:= xlPivotTableVersion12
表格("Sheet1")。选择
问题是此代码仅在数据小于65536时有效行!通常,我的报告中的文件有更多的行。
我需要你的帮助才能找到另一种方法在VBA中进行数据透视表...
非常感谢..
有关 的问题,请参阅此主题的论坛链接VBA 。>>
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/c147bae1-c9db-4ae8-9557-43713004cc94
< br。>或看到。>>
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/717e3fc3-8840-446d-8b7a-55a4052f48d6
我我不确定EXCEL 2007,但我认为65536是早期版本的最大行数。
问候,
约翰
Hi,
I'm creating a macro to run a report in Excel 2007. The excel file has more than 13479038 cells (aprox 1035863 rows and 16 columns).
I need to create a pivot table from my data. The code in VBA looks like:
Dim veryFinalRow As Variant
veryFinalRow = Range("P1048576").End(xlUp).Row
Sheets.Add
Sheets("CBW12F.tmp").Select
'Create Pivot table in Sheet1
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
Sheets(CBW12F.tmp).Range(Cells(1, 1), Cells(veryFinalRow, 16)), Version:=xlPivotTableVersion12). _
CreatePivotTable TableDestination:="Sheet1!R3C1", TableName:="PivotTable1" _
, DefaultVersion:=xlPivotTableVersion12
Sheets("Sheet1").Select
The problem is that this code works only if the data has less than 65536 rows! and usually, the files in my reports have more rows.
I need your help to find another way to do the pivot table in VBA...
Thanks a lot..
Hi,
Please see this thread with regard a link to a forum for questions relating to VBA.>>
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/c147bae1-c9db-4ae8-9557-43713004cc94
or see.>>
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/717e3fc3-8840-446d-8b7a-55a4052f48d6
I'm not sure about EXCEL 2007 but I believe 65536 is the maximum number of rows for earlier versions.
Regards,
John
这篇关于使用超过65536行的Excel 2007文件在VBA中创建数据透视表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!