3 D Range Macro problem

contras

New Member
Joined
May 5, 2009
Messages
1
Hello,

I've just joined this interesting forum because I am looking for a solution to a problem. I checked a lot of threads and I couldn't find the right answer, so here it goes:

- I have Workbook 1 called "April", where there are 7 Sheets. Each of these sheets has a cell where is a total amount (euro).
- There is Workbook A with one cell where I want to use SUM function and add all of the total amounts from the Sheets of April
- I created a Macro where I recorded a 3-D range formula which works ok.

But the problem appears when I run this Macro to calculate the total amount into Workbook A but from a different Workbook, say from January or February and so on, because these reports are changing all the time. I get the error which shows me that the Macro referred to April and it didn't calculate the total amount from the new Workbook, say January.

Here is the formula that works for April:
=SUM('[April.xls]1:7'!$I$2:$I$3)

And the Macro code for this formula:

Windows("April.xls").Activate
Range("I2:I3").Select
Sheets(Array("1", "2", "3", "4", "5", "6", "7")).Select
Sheets("1").Activate
Windows("New Foaie de lucru Microsoft Excel.xls").Activate
Range("A1").Select
Selection.FormulaR1C1 = "=SUM('[April.xls]1:7'!R2C9:R3C9)"
End Sub


Could you please give me a hint how to make the formula so that it will update it every time I have a new report? Because now when I run it on a new report, it points always to April. And also, the number of sheets is different each time, how can I update the formula so that it will always calculate all of the sheets?

Thank you so much! :)
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

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