Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Exiting Sub when Selecting Cancel on vbOKCancel

Hi Again,

How would I make it to where if I select cancel from this msxbox...

MsgBox "Do You Want to Run the Activation/De-Activation Code Checker?",
vbOKCancel

....it exits the sub and does not perform anything else within the sub?
Right now if I select cancel it still finishes the sub. Any help would be
great.

Thanks Much,
Rob
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Exiting Sub when Selecting Cancel on vbOKCancel

Dim Resp as long
resp = msgbox(Prompt:="do you want...", buttons:=vbokcancel)
if resp = vbcancel then
exit sub
end if
'keep going

Rob wrote:

Hi Again,

How would I make it to where if I select cancel from this msxbox...

MsgBox "Do You Want to Run the Activation/De-Activation Code Checker?",
vbOKCancel

...it exits the sub and does not perform anything else within the sub?
Right now if I select cancel it still finishes the sub. Any help would be
great.

Thanks Much,
Rob


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Exiting Sub when Selecting Cancel on vbOKCancel

Rob-
As written your code pops up a message box with a prompt for the user,
and nothing happens when you click Cancel because there is no code to
accommodate any activity. By declaring a variable to hold the user's
answer, you can then act on it- try adding code like this:

Dim Response As String 'variable to hold user's answer
Response = MsgBox("Do You Want to Run the Activation/De-Activation
Code Checker?", vbOKCancel)
If Response = vbCancel Then
End
End If

You may want to use a vbYesNo instead of vbOKCancel, since that is a
slightly more intuitive answer to your "do you want to run this"
question.

Dave O


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Exiting Sub when Selecting Cancel on vbOKCancel

Rob-
As written your code pops up a message box with a prompt for the user,
and nothing happens when you click Cancel because there is no code to
accommodate any activity. By declaring a variable to hold the user's
answer, you can then act on it- try adding code like this:

Dim Response As String 'variable to hold user's answer
Response = MsgBox("Do You Want to Run the Activation/De-Activation
Code Checker?", vbOKCancel)
If Response = vbCancel Then
End
End If

You may want to use a vbYesNo instead of vbOKCancel, since that is a
slightly more intuitive answer to your "do you want to run this"
question.

Dave O


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Exiting Sub when Selecting Cancel on vbOKCancel

Rob-
As written your code pops up a message box with a prompt for the user,
and nothing happens when you click Cancel because there is no code to
accommodate any activity. By declaring a variable to hold the user's
answer, you can then act on it- try adding code like this:

Dim Response As String 'variable to hold user's answer
Response = MsgBox("Do You Want to Run the Activation/De-Activation
Code Checker?", vbOKCancel)
If Response = vbCancel Then
End
End If

You may want to use a vbYesNo instead of vbOKCancel, since that is a
slightly more intuitive answer to your "do you want to run this"
question.

Dave O




  #6   Report Post  
Posted to microsoft.public.excel.misc
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Exiting Sub when Selecting Cancel on vbOKCancel

Thanks Bunches!!

Rob

"Dave O" wrote:

Rob-
As written your code pops up a message box with a prompt for the user,
and nothing happens when you click Cancel because there is no code to
accommodate any activity. By declaring a variable to hold the user's
answer, you can then act on it- try adding code like this:

Dim Response As String 'variable to hold user's answer
Response = MsgBox("Do You Want to Run the Activation/De-Activation
Code Checker?", vbOKCancel)
If Response = vbCancel Then
End
End If

You may want to use a vbYesNo instead of vbOKCancel, since that is a
slightly more intuitive answer to your "do you want to run this"
question.

Dave O



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Exiting Sub when Selecting Cancel on vbOKCancel

Rob-
As written your code pops up a message box with a prompt for the user,
and nothing happens when you click Cancel because there is no code to
accommodate any activity. By declaring a variable to hold the user's
answer, you can then act on it- try adding code like this:

Dim Response As String 'variable to hold user's answer
Response = MsgBox("Do You Want to Run the Activation/De-Activation
Code Checker?", vbOKCancel)
If Response = vbCancel Then
End
End If

You may want to use a vbYesNo instead of vbOKCancel, since that is a
slightly more intuitive answer to your "do you want to run this"
question.

Dave O


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
Help exiting function needed !!! [email protected] Excel Worksheet Functions 0 September 22nd 06 03:18 PM
Disable Cut & Copy then restore on exiting sparx Excel Discussion (Misc queries) 0 April 30th 06 08:43 PM
HOW DO YOU GET EXCEL TO ASK IF YOU WANT TO SAVE A FILE ON EXITING David Lambright Excel Discussion (Misc queries) 3 October 15th 05 07:46 AM
Exiting Worksheet Evan Excel Discussion (Misc queries) 1 February 11th 05 06:06 PM
Troubleshoot when exiting Excel. Leirbag Excel Discussion (Misc queries) 1 December 7th 04 12:49 PM


All times are GMT +1. The time now is 04:55 PM.

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"