Runtime Error 1004: User Defined or Object Error

I had a serious problem ... well, maybe not Major, but I've been trying to figure it out since dinner yesterday.
I have the following code:

Application.CutCopyMode = False
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
    "Data!R7C1:R5000C40").CreatePivotTable TableDestination:= _
    "'[Master-File.xls]Analyse'!R20C14", TableName:="certain_view", DefaultVersion _
->   :=xlPivotTableVersion10

      

The runtime error is on the line with the arrow, but the whole bit above is highlighted in yellow.

Application-defined or object error

I am using Excel 2003, VBA. I have these multiple lines of script in my code five times and only this bit fails every time. I am trying to create a fifth pivot table with these rows.

I think it might have something to do with the amount of data in memory ... but Application.Cutopymode = False does not capture anyhting.

+1


source to share


2 answers


Fixed (previously, Remou pointed out that posting the answer is a good thing).
I'm a little confused.

My data was dynamic every time I reloaded a different set. Everything went fine in my test suite. Then, when I loaded the new set, the values ​​changed, the labels were added, the others were dropped ... one of my pivot tables got a lot bigger. The second one was programmed to be created in a specific cell, but that cell is now part of this larger table.



Not a very clear error message, but "it's been fixed."

Moral: Try to think of every possibility when assigning tables to worksheets.

+1


source


Just guess ... Is the ActiveWorkbook active? Have you tried using the named book?



0


source







All Articles