Vbyesno message box options

RosieRose

Board Regular
Joined
Jul 29, 2014
Messages
75
Hi there, I have a message box that displays text with yes and no buttons, but am having difficulty assigning the next steps according whether yes or no is clicked.
Code:
If MsgBox("Has the scheduling frequency changed during this period?", vbYesNo) Then If vb = yes Then MsgBox (" change the end date and complete summary from start date to freq change date")
I would like the macro to stop after the message is displayed to change the date, and if "No" is clicked, then the macro will continue. So far, I can't get the no part to work, nor can I get the macro to stop after the yes msgbox is displayed. I tried adding
Code:
Else if vb=no then
'code for macro to follow
I keep getting sintax errors or errors saying that I have an elseif without an if statement. Any help is greatly appreciated.
Code:
also could you please tell me how to skips lines (same as enter key) in this forum?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
RosieRose,

Try this construction...

Code:
Sub RR ()
If MsgBox("Has the scheduling frequency changed during this period?", vbYesNo) = vbYes Then
MsgBox (" change the end date and complete summary from start date to freq change date")
Else
MsgBox "No therefore do other code"
'Other code here
End If
End Sub

Hope that helps.

Not sure what you mean re skipping line in forum?
 
Upvote 0
Hi,
see if this change to your code helps:

Code:
Dim msg As Integer
    msg = MsgBox("Has the scheduling frequency changed during this period?", 36, "Frequency Change")
    If msg = vbYes Then
        MsgBox "Change the end date and complete summary" & Chr(10) & _
        "from start date to freq change date", 64, "Change End Date"
    Else
        'vbNo
        'code for macro to follow
    End If

Dave
 
Upvote 0
Perfect!!! thank you. What I mean by skipping lines, is that if I press the enter key, nothing happens. I cannot create paragraphs when writing in this forum. Thank you
 
Upvote 0
You are welcome.




:confused:I've just hit my enter key 5 times and it got me here!!???
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,210
Members
448,554
Latest member
Gleisner2

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