ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Msg Box in IF statement? (https://www.excelbanter.com/excel-discussion-misc-queries/148217-msg-box-if-statement.html)

Elise148

Msg Box in IF statement?
 
How would I go about putting a Msg Box in an IF statement in VBA???

For example, I would want to say, if something is clicked in another message
box, proceed with the macro, if something else is clicked, stop the macro?????



Toppers

Msg Box in IF statement?
 

On a MsgBox you can set the YES,NO,CANCEL buttons in msgbox parameters...

resp=Msgbox(........,VbYESNO)

IF resp=vbYES then

IF resp=VbNO then

HTH

"Elise148" wrote:

How would I go about putting a Msg Box in an IF statement in VBA???

For example, I would want to say, if something is clicked in another message
box, proceed with the macro, if something else is clicked, stop the macro?????



Elise148

Msg Box in IF statement?
 
Thanks! I'll give that a try!


"Toppers" wrote:


On a MsgBox you can set the YES,NO,CANCEL buttons in msgbox parameters...

resp=Msgbox(........,VbYESNO)

IF resp=vbYES then

IF resp=VbNO then

HTH

"Elise148" wrote:

How would I go about putting a Msg Box in an IF statement in VBA???

For example, I would want to say, if something is clicked in another message
box, proceed with the macro, if something else is clicked, stop the macro?????



Elise148

Msg Box in IF statement?
 
What if I want to run the whole macro if the answer is "Yes"...how do I end
the IF statement...right now it looks like...

resp = MsgBox("Do you want to run the macro?", vbYesNo, Confirm)
If resp = vbNo Then
MsgBox ("Macro stopped.")
Exit Sub

If resp = vbYes Then
Run = macro???????????
End If

"Toppers" wrote:


On a MsgBox you can set the YES,NO,CANCEL buttons in msgbox parameters...

resp=Msgbox(........,VbYESNO)

IF resp=vbYES then

IF resp=VbNO then

HTH

"Elise148" wrote:

How would I go about putting a Msg Box in an IF statement in VBA???

For example, I would want to say, if something is clicked in another message
box, proceed with the macro, if something else is clicked, stop the macro?????



Toppers

Msg Box in IF statement?
 
If resp = vbYes Then
macro1 '<=== runs macro1
End If


"Elise148" wrote:

What if I want to run the whole macro if the answer is "Yes"...how do I end
the IF statement...right now it looks like...

resp = MsgBox("Do you want to run the macro?", vbYesNo, Confirm)
If resp = vbNo Then
MsgBox ("Macro stopped.")
Exit Sub

If resp = vbYes Then
Run = macro???????????
End If

"Toppers" wrote:


On a MsgBox you can set the YES,NO,CANCEL buttons in msgbox parameters...

resp=Msgbox(........,VbYESNO)

IF resp=vbYES then

IF resp=VbNO then

HTH

"Elise148" wrote:

How would I go about putting a Msg Box in an IF statement in VBA???

For example, I would want to say, if something is clicked in another message
box, proceed with the macro, if something else is clicked, stop the macro?????



Elise148

Msg Box in IF statement?
 
What if the IF statement is IN macro1? Will the "yes" part cause the IF
statement to run AGAIN in the macro? Is there a way to tell it to continue
with the macro, instead of run it from the beginning??


"Toppers" wrote:

If resp = vbYes Then
macro1 '<=== runs macro1
End If


"Elise148" wrote:

What if I want to run the whole macro if the answer is "Yes"...how do I end
the IF statement...right now it looks like...

resp = MsgBox("Do you want to run the macro?", vbYesNo, Confirm)
If resp = vbNo Then
MsgBox ("Macro stopped.")
Exit Sub

If resp = vbYes Then
Run = macro???????????
End If

"Toppers" wrote:


On a MsgBox you can set the YES,NO,CANCEL buttons in msgbox parameters...

resp=Msgbox(........,VbYESNO)

IF resp=vbYES then

IF resp=VbNO then

HTH

"Elise148" wrote:

How would I go about putting a Msg Box in an IF statement in VBA???

For example, I would want to say, if something is clicked in another message
box, proceed with the macro, if something else is clicked, stop the macro?????



Elise148

Msg Box in IF statement?
 
Nevermind. I get it. Ha ha. Thanks SO much for your help!!!


"Toppers" wrote:

If resp = vbYes Then
macro1 '<=== runs macro1
End If


"Elise148" wrote:

What if I want to run the whole macro if the answer is "Yes"...how do I end
the IF statement...right now it looks like...

resp = MsgBox("Do you want to run the macro?", vbYesNo, Confirm)
If resp = vbNo Then
MsgBox ("Macro stopped.")
Exit Sub

If resp = vbYes Then
Run = macro???????????
End If

"Toppers" wrote:


On a MsgBox you can set the YES,NO,CANCEL buttons in msgbox parameters...

resp=Msgbox(........,VbYESNO)

IF resp=vbYES then

IF resp=VbNO then

HTH

"Elise148" wrote:

How would I go about putting a Msg Box in an IF statement in VBA???

For example, I would want to say, if something is clicked in another message
box, proceed with the macro, if something else is clicked, stop the macro?????



Toppers

Msg Box in IF statement?
 
just code the vbNO response and the macro will continue on the next statement

resp = MsgBox("Do you want to run the macro?", vbYesNo, Confirm)
If resp = vbNo Then
MsgBox ("Macro stopped.")
Exit Sub
End if

.... macro continues here ...

HTH

"Elise148" wrote:

What if the IF statement is IN macro1? Will the "yes" part cause the IF
statement to run AGAIN in the macro? Is there a way to tell it to continue
with the macro, instead of run it from the beginning??


"Toppers" wrote:

If resp = vbYes Then
macro1 '<=== runs macro1
End If


"Elise148" wrote:

What if I want to run the whole macro if the answer is "Yes"...how do I end
the IF statement...right now it looks like...

resp = MsgBox("Do you want to run the macro?", vbYesNo, Confirm)
If resp = vbNo Then
MsgBox ("Macro stopped.")
Exit Sub

If resp = vbYes Then
Run = macro???????????
End If

"Toppers" wrote:


On a MsgBox you can set the YES,NO,CANCEL buttons in msgbox parameters...

resp=Msgbox(........,VbYESNO)

IF resp=vbYES then

IF resp=VbNO then

HTH

"Elise148" wrote:

How would I go about putting a Msg Box in an IF statement in VBA???

For example, I would want to say, if something is clicked in another message
box, proceed with the macro, if something else is clicked, stop the macro?????



Elise148

Msg Box in IF statement?
 
Thanks soo much! Again!

"Toppers" wrote:

just code the vbNO response and the macro will continue on the next statement

resp = MsgBox("Do you want to run the macro?", vbYesNo, Confirm)
If resp = vbNo Then
MsgBox ("Macro stopped.")
Exit Sub
End if

... macro continues here ...

HTH

"Elise148" wrote:

What if the IF statement is IN macro1? Will the "yes" part cause the IF
statement to run AGAIN in the macro? Is there a way to tell it to continue
with the macro, instead of run it from the beginning??


"Toppers" wrote:

If resp = vbYes Then
macro1 '<=== runs macro1
End If


"Elise148" wrote:

What if I want to run the whole macro if the answer is "Yes"...how do I end
the IF statement...right now it looks like...

resp = MsgBox("Do you want to run the macro?", vbYesNo, Confirm)
If resp = vbNo Then
MsgBox ("Macro stopped.")
Exit Sub

If resp = vbYes Then
Run = macro???????????
End If

"Toppers" wrote:


On a MsgBox you can set the YES,NO,CANCEL buttons in msgbox parameters...

resp=Msgbox(........,VbYESNO)

IF resp=vbYES then

IF resp=VbNO then

HTH

"Elise148" wrote:

How would I go about putting a Msg Box in an IF statement in VBA???

For example, I would want to say, if something is clicked in another message
box, proceed with the macro, if something else is clicked, stop the macro?????




All times are GMT +1. The time now is 02:20 AM.

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