Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default PivotCaches.Add

Hi,
I'm making a pivot table from data imported to a
spreadsheet. It works just fine in XP, however it will
not perform in Excel 2000. Code:

Dim PivotRange as Range
..
Set PivotRange = Worksheets(1).UsedRange
..
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase _
SourceData:=PivotRange).CreatePivotTable _
TableDestination:="", TableName:="MvsC"

When reaching the line where the table is created Excel
just quits the current sub and returns to the calling. If
I change the SourceData from the PivotRange variable to
an absolute address like "'Sheet1'!R1C1:R12C20" it works
fine, but that is quite an inconvenient way.
Anybody know why this happens to me?
Any help appreciated.

ojv
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default PivotCaches.Add

In Excel 2000, SourceData requires a string. The following should work
in both versions:
'===================================
Dim PivotRange As Range
Dim strPR As String
'
Set PivotRange = Worksheets(1).UsedRange
strPR = PivotRange.Address
'
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
SourceData:=strPR).CreatePivotTable _
TableDestination:="", TableName:="MvsC"
'======================================

jacob wrote:
Hi,
I'm making a pivot table from data imported to a
spreadsheet. It works just fine in XP, however it will
not perform in Excel 2000. Code:

Dim PivotRange as Range
.
Set PivotRange = Worksheets(1).UsedRange
.
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase _
SourceData:=PivotRange).CreatePivotTable _
TableDestination:="", TableName:="MvsC"

When reaching the line where the table is created Excel
just quits the current sub and returns to the calling. If
I change the SourceData from the PivotRange variable to
an absolute address like "'Sheet1'!R1C1:R12C20" it works
fine, but that is quite an inconvenient way.
Anybody know why this happens to me?
Any help appreciated.

ojv



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default PivotCaches.Add

Of course!. Thank you for taking the time.
-----Original Message-----
In Excel 2000, SourceData requires a string. The

following should work
in both versions:
'===================================
Dim PivotRange As Range
Dim strPR As String
'
Set PivotRange = Worksheets(1).UsedRange
strPR = PivotRange.Address
'
ActiveWorkbook.PivotCaches.Add(SourceType:=xlData base, _
SourceData:=strPR).CreatePivotTable _
TableDestination:="", TableName:="MvsC"
'======================================

jacob wrote:
Hi,
I'm making a pivot table from data imported to a
spreadsheet. It works just fine in XP, however it will
not perform in Excel 2000. Code:

Dim PivotRange as Range
.
Set PivotRange = Worksheets(1).UsedRange
.
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase _
SourceData:=PivotRange).CreatePivotTable _
TableDestination:="", TableName:="MvsC"

When reaching the line where the table is created

Excel
just quits the current sub and returns to the calling.

If
I change the SourceData from the PivotRange variable

to
an absolute address like "'Sheet1'!R1C1:R12C20" it

works
fine, but that is quite an inconvenient way.
Anybody know why this happens to me?
Any help appreciated.

ojv



--
Debra Dalgleish
Excel FAQ, Tips & Book List
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
change commandtext in pivotcaches patrick Excel Programming 3 September 2nd 03 03:06 PM


All times are GMT +1. The time now is 05:07 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"