![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
.
Join Date: Feb 2002
Location: Akron, Ohio USA
Posts: 789
|
This is driving me crazy. This line of code is working in Excel 2002, and failing in Excel 2000.
Dim PTCache as PivotCache Set MyRange = Range("StyleCache") Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDataBase, SourceData:=MyRange) It is failing with Run Time Error '5': Invalid Procedure Call or Argument. What the heck? There are only 2 arguments. xlDataBase has a value of 1 in both systems. MyRange is valid, has 3 columns, with headings of Store, Style, "Sales 7", and 330 rows of data. Any ideas? Bill
__________________
Preview my latest book for Free |
|
|
|
|
|
#2 |
|
BatCoder
Join Date: Feb 2002
Location: Turkey
Posts: 764
|
Hi Bill,
Did you try this? Dim PTCache As PivotCache Set MyRange = Range("A1:B10") Set PTCache = ActiveWorkbook.PivotCaches.Add(xlDatabase, MyRange) Suat |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
The problem seems to be with your Range variable, as the following works OK, with the myRange commented out: -
Dim PTCache As PivotCache 'Set myrange = Range("stylecache") Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:="=stylecache") No idea why this works with Excel 2002 and not 2000 though. Edit: Sorry, missed out an '=' above. [ This Message was edited by: Mudface on 2002-05-04 12:30 ] |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
The following should work as well: -
Dim PTCache As PivotCache Dim myRange As String myRange = Sheet1.Range("StyleCache").Address Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, _ SourceData:=myRange) [ This Message was edited by: Mudface on 2002-05-04 12:42 ] |
|
|
|
|
|
#5 |
|
.
Join Date: Feb 2002
Location: Akron, Ohio USA
Posts: 789
|
Suat & Mudface: This board is a fantastic resource. Thanks for the help. Mudface - I tried the "=stylecache" first and it worked wonderfully.
Bill _________________ MrExcel.com Consulting [ This Message was edited by: MrExcel on 2002-05-04 14:04 ] |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Las Vegas Nevada USA
Posts: 240
|
Just a thought from the peanut gallery.
If your source data is not a DYNAMIC RANGE then I urge you to get familiar with this concept. Check my last post on page 5 or maybe 6. Aladin stepped me through it and it is great stuff.
__________________
George Learn to listen. Opportunity sometimes knocks very softly. |
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
Is this a bug or a mistake in the documentation, do you think? The SourceData arguement is specified as an optional or required variant, but seems to be a required string in Excel 2000. Has this changed for 2002?
|
|
|
|
|
|
#8 |
|
.
Join Date: Feb 2002
Location: Akron, Ohio USA
Posts: 789
|
They probably just "eased up" the requirements in Excel 2002. Change is good - it just makes cross platform deployment a little more crazy.
__________________
Preview my latest book for Free |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|