MsgBox question

dukeofscouts

Board Regular
Joined
Jan 19, 2009
Messages
146
Here is my plan, I've got a msgbox in VByesno format. What I'd like to do is set the next action to be as follows
If Yes then MsgBox 1 (VBokonly)
If No then MsgBox 2 (Vbokonly)
Run rest of sub

how can I get this result?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Try

Code:
If MsgBox("question here", vbYesNo + vbQuestion) = vbYes Then
    MsgBox "one"
Else
    MsgBox "two"
End If
 
Upvote 0
Code:
Sub MsgBoxOption()
rspn = MsgBox("Choose", vbYesNo)
If rspn = vbYes Then
    MsgBox "Number1"
Else: MsgBox "Number2"
End If
End Sub

lenze
 
Upvote 0
Hmm slight glitch let me copy the VBA I have so far maybe you can see what is wrong... I must be missing a line of code here some where:

If MsgBox("Did you finish the puzzel", vbYesNo + vbQuestion) = ybyes Then
MsgBox("Way to go", vbOKOnly) = vbOK
Else
MsgBox("Better luck next time", vbOKOnly) = vbOK
End If
 
Upvote 0
Rich (BB code):
If MsgBox("Did you finish the puzzel", vbYesNo + vbQuestion) = vbYes Then
    MsgBox "Way to go", vbOKOnly
Else
    MsgBox "Better luck next time", vbOKOnly
End If
 
Upvote 0
ok so if it is a result no brackets... I really need to find a class in this stuff! Just way too much fun.

Thanks VoG,
D.O.S.
 
Upvote 0
Lt me step back in and help (or confuse) you some
Both VoG's
Code:
If MsgBox("Did you finish the puzzel", vbYesNo + vbQuestion) = vbYes
and my
Code:
rspn = MsgBox("Choose", vbYesNo)
require brackets as the result is being evaluated. This, however, does not
Code:
MsgBox "Way to go", vbOKOnly
because it is informational only. It does not hurt, however, to use brackets here
Code:
MsgBox ("Way to go", vbOKOnly)
It's just that a lot of us are lazy.
lenze
 
Upvote 0
Ok I see it now. You know it is kind of funny, I've learned more from this site in the last three weeks than in the six months I spent in the college class room learning "Advanced Excel". You all are amazing!
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,731
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top