#1   Report Post  
Posted to microsoft.public.excel.programming
T. T. is offline
external usenet poster
 
Posts: 6
Default PivotCache

I am using MS Dynamics GP SmartList Export Solution. The code to create a
pivot chart when I export the SmartList includes this:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Sheet1!R1C1:R322C14").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10

I want to replace the second line: "Sheet1!R1C1:R322C14" with variables
that will change depending on the row number in the SmartList I am exporting.
The number of rows will vary from day to day depending on the number of open
transactions.

The range of the data for the pivot chart will always go from A1 to Last
Cell. I can capture the address of the last cell, but I can't figure out how
to replace the hard coded range with the variables. Right now I am setting
A1 as the value of a variable called HomeCell and whatever the last cell
address is for the value of a variable called CellRef. However when I change
the PivotCache to read:

"Sheet1!HomeCell, CellRef"

I get an error. I have seen this done before so I know it is possible, but
I cannot remember the syntax. Can anyone help?

Thanks.

T.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default PivotCache

You could use the address of the current region, e.g.:

'=======================
Dim rngSource As Range
Dim strRng As String
Set rngSource = Worksheets("Sheet1").Range("A1").CurrentRegion
strRng = "Sheet1!" & rngSource.Address

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
SourceData:=strRng).CreatePivotTable TableDestination:="", _
TableName:="PivotTable3"
'=======================

T. wrote:
I am using MS Dynamics GP SmartList Export Solution. The code to create a
pivot chart when I export the SmartList includes this:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"Sheet1!R1C1:R322C14").CreatePivotTable TableDestination:="",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10

I want to replace the second line: "Sheet1!R1C1:R322C14" with variables
that will change depending on the row number in the SmartList I am exporting.
The number of rows will vary from day to day depending on the number of open
transactions.

The range of the data for the pivot chart will always go from A1 to Last
Cell. I can capture the address of the last cell, but I can't figure out how
to replace the hard coded range with the variables. Right now I am setting
A1 as the value of a variable called HomeCell and whatever the last cell
address is for the value of a variable called CellRef. However when I change
the PivotCache to read:

"Sheet1!HomeCell, CellRef"

I get an error. I have seen this done before so I know it is possible, but
I cannot remember the syntax. Can anyone help?

Thanks.

T.



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

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
Can I add an item to a PivotCache with VBA? John Brock Excel Discussion (Misc queries) 4 June 16th 08 01:00 PM
Pivotcache Pivot Table Pete Excel Programming 1 August 5th 06 12:38 PM
Update PivotCache Staaan Excel Programming 0 November 30th 05 10:49 AM
Delete PivotCache sorin Excel Programming 1 June 21st 05 09:03 PM


All times are GMT +1. The time now is 02:50 PM.

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"