ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   halting macro (https://www.excelbanter.com/excel-programming/271162-halting-macro.html)

Jonas O

halting macro
 
Hi again,
lots of questions from here and thanks for all the good answers! Really
helped.

Another question is how to make a dialogbox where you answer a question
(yes or no answer) were a positive answer would continue to run the
reminding macro while a negative answer would halt the macro right
there.

Is there such an code to resolve this as well?

Kind regards

Jonas

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Patrick Molloy[_3_]

halting macro
 
For example

IF Msgbox("Continue?",vbYesNo,"Pause")=VBNo Then
Exit Sub
End If

Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
Hi again,
lots of questions from here and thanks for all the good

answers! Really
helped.

Another question is how to make a dialogbox where you

answer a question
(yes or no answer) were a positive answer would continue

to run the
reminding macro while a negative answer would halt the

macro right
there.

Is there such an code to resolve this as well?

Kind regards

Jonas

*** Sent via Developersdex http://www.developersdex.com

***
Don't just participate in USENET...get rewarded for it!
.


Leyton

halting macro
 
Jonas

If you use the built in msgBox dialog:

Sub test()
Dim iResult As Integer

iResult = MsgBox("Do You want to continue?",
vbYesNo, "Test")
If iResult = vbNo Then
Exit Sub
End If
' Do the rest
End Sub

Note that vbYes, vbNo (and the others) all return an
integer value which you can test for or use the constants
as above

HTH

Leyton


-----Original Message-----
Hi again,
lots of questions from here and thanks for all the good

answers! Really
helped.

Another question is how to make a dialogbox where you

answer a question
(yes or no answer) were a positive answer would continue

to run the
reminding macro while a negative answer would halt the

macro right
there.

Is there such an code to resolve this as well?

Kind regards

Jonas

*** Sent via Developersdex http://www.developersdex.com

***
Don't just participate in USENET...get rewarded for it!
.


Esco

halting macro
 
Here is an example.

sub Test()
dim usrchoice
usrchoice=msgbox("Do You want to continue?",vbyesno)
if usrchoice=vbno then end
msgbox "To be continued..."
end

-----Original Message-----
Hi again,
lots of questions from here and thanks for all the good

answers! Really
helped.

Another question is how to make a dialogbox where you

answer a question
(yes or no answer) were a positive answer would continue

to run the
reminding macro while a negative answer would halt the

macro right
there.

Is there such an code to resolve this as well?

Kind regards

Jonas

*** Sent via Developersdex http://www.developersdex.com

***
Don't just participate in USENET...get rewarded for it!
.



All times are GMT +1. The time now is 06:52 AM.

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