Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search function keeps quitting in Excel Rebecca[_2_] Excel Worksheet Functions 0 February 20th 07 12:41 AM
quitting worksheet then excel if.... JNW Excel Programming 3 November 6th 05 09:52 PM
Problem quitting excel when it is used by ASP.NET application Tom Excel Programming 0 May 10th 04 08:35 PM
Quitting Excel without saving manishc[_2_] Excel Programming 1 November 16th 03 11:55 AM
Quitting a User Form Bob Kaku Excel Programming 1 August 15th 03 08:46 PM


All times are GMT +1. The time now is 09:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"