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
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Watch MrExcel Video

Forum statistics

Threads
1,123,334
Messages
5,601,012
Members
414,421
Latest member
tonybear1994

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
Top