Macros with switches

G

Guest

I have doubt with macro coding.
I have three macros to run.
In first step: If user press a macro button it has to run the Macro1, after
running this, there is one message box will popup asking for “Yes†or “Noâ€
Now question is If user select “Ok†it should run the macro2 and If user
select “No†it should run the macro3.
Just I want to know how to link the Macro 2 and Macro3 after message box
message button.
Should I use "Buttons" in between macros????????????????
I hope this make sense.
Regards,
Vishu
 
B

Bunter_22

Hi Vishu,

Whether to use msgbox's between macros is up to you, it depends on what
you are trying to do and what reasons you may need to stop the macros
for.

To link them do the following:

Before the End Sub in Macro1 put the following:

If Msgbox("Would you like Macro2 to now run?", VBYesNo,"Macro2") =
VbYes then
Call Macro2
Endif

You will need to replace Macro2 with what ever you have called it etc.
You can put the same at the bottom of Macro2 changing the name of
Macro2 to Macro3 etc.

Regards,

James
 
B

Bob Phillips

ans = MsgBox("Yes or No"£, vbYesNo"
If ans = vbYes Then
Call macro2
Else
Call macro3
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Macro linking 2
Close w/o saving changes 6
Windows Message when Directory Already Exist 2
Interupt code with message before it runs 4
Swithces in Macro 1
Macro conflict 4
Macro conflict 1
Macro creation via VBA 26

Top