halting macro

J

Jonas O

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!
 
H

Hervé Hanuise

Hi !

put this into a new module : it works !

Option Explicit
Public titre$, defaut$, question$, reponse$
Sub continue_yes_or_no()
'here we start something
titre$ = "Info..."
question$ = "here we are..."
MsgBox question$
'now comes the question
titre$ = "Info..."
question$ = "Shall we continue" & vbCrLf & "---------
<Y>es or <N>o ?"
defaut$ = ""
reponse$ = InputBox(question$, titre$, defaut$)
If Left(UCase(reponse$), 1) = "N" Then
MsgBox "The answer is no: we stop"
Exit Sub
End If
MsgBox "The answer is Yes"
MsgBox "So we continue..."
'and here you go with your code....
'...

End Sub



regards+
Hervé+++
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top