Calling a macro from within a Macro, or writing a subroutine

Brat

New Member
Joined
Dec 5, 2002
Messages
6
It seems like it should be easy, but the debugger keeps telling me I am wrong. Soo...

I have written a macro, let's call it "BeenThere".

While running the BeenThere macro want to run the macro DoneThat and then continue the BeenThere macro.

I attempted to figure this out with MSHelp, it tells me that I can't call a subroutine from a subroutine. Are macros subroutines?

Is there a way to pull this off?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Re: Calling a macro from within a Macro, or writing a subrou

you can call a macro from within another macro...perhaps you could post a sample of your code, and also post which line specifically it is getting caught on

kevin
 
Upvote 0
Re: Calling a macro from within a Macro, or writing a subrou

private sub beenthere()

(blah blah blah beenthere code)

donethat 'macro we want to run in beenthere

(blah blah blah more code for been there)

end sub

Its that easy, just place the name of the procedure where you want it to run.

DaK
 
Upvote 0
Re: Calling a macro from within a Macro, or writing a subrou

Yes... A couple of things to check:

1. Are you passing any variables between the macros? If so you need to type "Call DoneThat(WhatEverVar)."

2. Make sure you Sub is not Private DoneThat. If so change it to Public DoneThat.

Hope this helps!
 
Upvote 0
Re: Calling a macro from within a Macro, or writing a subrou

Thanks folks. I got it to run.

Gayle
 
Upvote 0

Forum statistics

Threads
1,221,709
Messages
6,161,431
Members
451,705
Latest member
Priti_190

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