Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quitting Macro
I have a macro that includes many message boxes that lead to sub-routines.
E.g.: ..... If MsgBox("Do you have an F854 this month?", vbYesNo) = vbYes Then Call ImportF854 End If ...... I want to build in an option that would allow the user to quit the macro at any of these prompts. I want to give the user the instruction that they could enter a "^" character for example at the message prompt and the macro would then close. Is there a "graceful" way to code this? -- Ken Hudson |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quitting Macro
you can try this
If MsgBox("Do you have an F854 this month?", vbYesNo) = vbYes Then Call ImportF854 else exit sub End If -- Gary "Ken Hudson" wrote in message ... I have a macro that includes many message boxes that lead to sub-routines. E.g.: .... If MsgBox("Do you have an F854 this month?", vbYesNo) = vbYes Then Call ImportF854 End If ..... I want to build in an option that would allow the user to quit the macro at any of these prompts. I want to give the user the instruction that they could enter a "^" character for example at the message prompt and the macro would then close. Is there a "graceful" way to code this? -- Ken Hudson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quitting Macro
Why not use VbYesNoCancel
Dim lAns as Long lAns = MsgBox("Do you have an F854 this month?" & _ vbNewline & "Hit cancel to quit", vbYesNoCancel) if lAns = vbYes then Call ImportF854 elseif lAns = vbCancel then exit sub End If -- Regards, Tom Ogilvy "Ken Hudson" wrote: I have a macro that includes many message boxes that lead to sub-routines. E.g.: .... If MsgBox("Do you have an F854 this month?", vbYesNo) = vbYes Then Call ImportF854 End If ..... I want to build in an option that would allow the user to quit the macro at any of these prompts. I want to give the user the instruction that they could enter a "^" character for example at the message prompt and the macro would then close. Is there a "graceful" way to code this? -- Ken Hudson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quitting Macro
That will work.
Thanks Tom. -- Ken Hudson "Tom Ogilvy" wrote: Why not use VbYesNoCancel Dim lAns as Long lAns = MsgBox("Do you have an F854 this month?" & _ vbNewline & "Hit cancel to quit", vbYesNoCancel) if lAns = vbYes then Call ImportF854 elseif lAns = vbCancel then exit sub End If -- Regards, Tom Ogilvy "Ken Hudson" wrote: I have a macro that includes many message boxes that lead to sub-routines. E.g.: .... If MsgBox("Do you have an F854 this month?", vbYesNo) = vbYes Then Call ImportF854 End If ..... I want to build in an option that would allow the user to quit the macro at any of these prompts. I want to give the user the instruction that they could enter a "^" character for example at the message prompt and the macro would then close. Is there a "graceful" way to code this? -- Ken Hudson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Search function keeps quitting in Excel | Excel Worksheet Functions | |||
quitting worksheet then excel if.... | Excel Programming | |||
Problem quitting excel when it is used by ASP.NET application | Excel Programming | |||
Quitting Excel without saving | Excel Programming | |||
Quitting a User Form | Excel Programming |