• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 690
  • Last Modified:

Reference is not valid

Hi I am getting an error (Reference is not valid) for

 ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
              "mbPerFileFromPerl" & Sheets("mbPerFileFromPerl").Range("A1").CurrentRegion.Address(ReferenceStyle:=xlR1C1), Version:=xlPivotTableVersion14). _
              CreatePivotTable TableDestination:="", TableName:="PivotTable7" _
              , DefaultVersion:=xlPivotTableVersion14

But not for this one
             ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
              "perStockTweets!" & Sheets("perStockTweets").Range("A1").CurrentRegion.Address(ReferenceStyle:=xlR1C1), Version:=xlPivotTableVersion14). _
              CreatePivotTable TableDestination:="", TableName:="PivotTable6" _
              , DefaultVersion:=xlPivotTableVersion14

Can anyone say why that would be?
0
willie108
Asked:
willie108
  • 2
1 Solution
 
willie108Author Commented:
I searched on the web and it may be that dynamic named range  is necessary but I am not sure how to set that up.
0
 
jmcmunnCommented:
It has to be an issue with the SourceData not being valid or the sheet being invalid.  Check the inner exception on the error if there is one.  it's impossible to say for sure without more info.
0
 
Robert SchuttSoftware EngineerCommented:
It seems they are very similar with 1 exception, can you try changing
"mbPerFileFromPerl"

Open in new window

to:
"mbPerFileFromPerl!"

Open in new window

?
0
 
willie108Author Commented:
shoot. I missed that. THANKS!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now