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?
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,651
Try

Code:
If MsgBox("question here", vbYesNo + vbQuestion) = vbYes Then
    MsgBox "one"
Else
    MsgBox "two"
End If
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
Code:
Sub MsgBoxOption()
rspn = MsgBox("Choose", vbYesNo)
If rspn = vbYes Then
    MsgBox "Number1"
Else: MsgBox "Number2"
End If
End Sub
lenze
 

dukeofscouts

Board Regular
Joined
Jan 19, 2009
Messages
146
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
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,651
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
 

dukeofscouts

Board Regular
Joined
Jan 19, 2009
Messages
146
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.
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
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
 

dukeofscouts

Board Regular
Joined
Jan 19, 2009
Messages
146
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!
 

Forum statistics

Threads
1,081,545
Messages
5,359,438
Members
400,528
Latest member
Ratish52

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top