Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Creating an older version pivottable

Hi

How to programmatically create an older version of pivottable in Excel 2007?

Kind regards
IgorM

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,480
Default Creating an older version pivottable

Hi Igor

in XL2007 the code would look something like
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDa tabase, SourceData:= _
"Sheet1!R1C1:R9C3", Version:=xlPivotTableVersion12).CreatePivotTable
_
TableDestination:="", TableName:="PivotTable3", DefaultVersion:= _
xlPivotTableVersion12
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable3").PivotFields ("Year")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable3").PivotFields ("Product")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable3").AddDataFiel d
ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("Value"), "Sum of Value", xlSum

For XL2003 the code would be
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Sheet2!R1C1:R9C3").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable2", DefaultVersion:=xlPivotTableVersion10
ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.Cells(3, 1).Select
With ActiveSheet.PivotTables("PivotTable2").PivotFields ("Year")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable2").PivotFields ("Product")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable2").AddDataFiel d
ActiveSheet.PivotTables( _
"PivotTable2").PivotFields("Value"), "Sum of Value", xlSum
End Sub

So the difference is that when you create your code in XL2007 (using macro
recorder for example), then just edit the generated code to change
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDa tabase
to
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase

and change
DefaultVersion:= _
xlPivotTableVersion12
to
DefaultVersion:= _
xlPivotTableVersion10

--
Regards
Roger Govier

"IgorM" wrote in message
...
Hi

How to programmatically create an older version of pivottable in Excel
2007?

Kind regards
IgorM

__________ Information from ESET Smart Security, version of virus
signature database 4798 (20100122) __________

The message was checked by ESET Smart Security.

http://www.eset.com




__________ Information from ESET Smart Security, version of virus signature database 4799 (20100123) __________

The message was checked by ESET Smart Security.

http://www.eset.com



Reply
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
Saving a newer version of Excel using an older version (Excel 97) Alain Dekker Excel Discussion (Misc queries) 7 April 3rd 10 11:02 PM
Sharing with older version Sam C Excel Discussion (Misc queries) 3 December 15th 08 09:46 PM
older version and newer version of excel Nanofish Excel Programming 5 July 7th 08 07:51 PM
saving to older version of excel Jim Griffin Excel Discussion (Misc queries) 0 October 4th 06 11:35 PM
how do I open older version of file sharon Excel Discussion (Misc queries) 3 October 8th 05 03:15 PM


All times are GMT +1. The time now is 11:53 AM.

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

About Us

"It's about Microsoft Excel"