Using "Call" In a Macro

Ste_Moore01

Active Member
Joined
Jul 13, 2005
Messages
467
Hi,

I've created a macro that needs to "call" another macro

i.e.
Code:
 Sub Macro1()
    Workbooks.Open Filename:="C:\Test.xls"
    Call Macro2
    Workbooks.Open Filename:="C:\Test1.xls"
    Workbooks.Open Filename:="C:\Test2.xls"
    Workbooks.Open Filename:="C:\Test3.xls"
    Workbooks.Open Filename:="C:\Test4.xls"
    Workbooks.Open Filename:="C:\Test5.xls"
End Sub
Is it possible for Macro2 to end Macro1?

In Macro2 I have some code which checks to see if a certain cell is true. If it is then the macro will continue, if not I want macro1 and macro2 to end.

Is this possible at all?
 

iggydarsa

Well-known Member
Joined
Jun 28, 2005
Messages
1,647
Maybe you can use macro2 as a Function instead of Sub and returns True or False value and in macro1 you test it, if it is False you can End macro1.

Just an idea...
 

Ste_Moore01

Active Member
Joined
Jul 13, 2005
Messages
467
I've tried using "End" instead of "Exit Sub" and it works perfectly for me.

Thanks Andrew!

Iggydarsa, I'm unsure how you would change it to a function and test it etc.. but thanks for the suggestion.
 

Forum statistics

Threads
1,078,005
Messages
5,337,691
Members
399,160
Latest member
Vantone

Some videos you may like

This Week's Hot Topics

Top