ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Swithces in Macro (https://www.excelbanter.com/excel-discussion-misc-queries/57905-swithces-macro.html)

vishu

Swithces in Macro
 
Hi,
I have 3 macros to run.
When user run first macro, it will ask for Yes or No option.
If user select €œyes€ automatically 2 macro should run, If user selects €œNo€
3 macro should run.
Can you please tell me how to write switches between these three macro?

Regards,
Vishu


Bob Phillips

Swithces in Macro
 
Write them as functions and return the result. As an example

Sub Macro1()
Dim ans
ans = MsgBox("Macro1", vbYesNo)
If ans = vbYes Then
If Func2 = vbYes Then
Func3
End If
End If
End Sub

Function Func2()
Dim ans
ans = MsgBox("Func2", vbYesNo)
Func2 = ans
End Function

Function Func3()
Dim ans
ans = MsgBox("Func3", vbYesNo)
Func3 = ans
End Function

--

HTH

RP
(remove nothere from the email address if mailing direct)


"vishu" wrote in message
...
Hi,
I have 3 macros to run.
When user run first macro, it will ask for Yes or No option.
If user select "yes" automatically 2 macro should run, If user selects

"No"
3 macro should run.
Can you please tell me how to write switches between these three macro?

Regards,
Vishu





All times are GMT +1. The time now is 09:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com