Running a Macro within a Macro!

welly_music

New Member
Joined
Jul 21, 2010
Messages
5
Hi there.

I have recorded a large macro to automate a few things ain a spreadsheet, and in this I have run a macro in the same workbook a number of times as follows :

Application.Run _
"myfilename.xlsm'!Calculate_residual"

When I save an iteration of this spreadsheet (it is a working property model), the code still points to the original document........ is there any way of removing this "myfilename.xlsm' reference so that the macro refers to the Calculate_residual macro in the saved iteration (ie current document) instead of the old version of the model where the macro was first recorded?

Thanks!
 

Some videos you may like

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,667
If your current macro is running from Workbook1 you can call any other macro found on the same workbook by simply using
Code:
Call MyMacro
If you start your macro from "Workbook1" and your macro runs another macro from "Workbook2" that calls for yet another macro, the Call refers now to macros found from "Workbook2". When they're done the original macro takes over and once again the Call refers to macros found from "Workbook1" (=always the same workbook that the macro is running from).
 

Watch MrExcel Video

Forum statistics

Threads
1,122,464
Messages
5,596,288
Members
414,052
Latest member
Dual Showman

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