Run-time Error "1004'

carcanken

New Member
Joined
Oct 15, 2014
Messages
6
I am trying to create a Pivot Table using a range that is stored in cell "A1" using the code below.
ActiveWorkbook.PivotCaches.Create(SourceType:=xlConsolidation, SourceData:= _
Range([indirect("a1")]).Value, Version:=xlPivotTableVersion15).CreatePivotTable _
TableDestination:="", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion15
The Error is somewhere in the block above. I think it has something to do with how I am wanting to assign the SourceData. If I replace Range([indirect("a1")]).Value with what is stored in Cell A1 it will work but I need to be able to use the cell contents as my Ranges will vary.
This is what I have in Cell A1. Array(Array("'D0061'!R1C4:R65C52", "D0061"), Array("'D0411'!R1C4:R65C52", "D0411"), Array("'D0822'!R1C4:R65C52", "D0822"), Array("'D0999'!R1C4:R65C52", "D0999"))

I have just tried Range("A1").value, Cell("A1").value, assigned the value in A1 to a String Nothing has been working. Not sure what I am missing.

Any help would be appreciated.
Car
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,641
Messages
6,120,695
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top