ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I program a message box with a (Yes),( No) buttons (https://www.excelbanter.com/excel-programming/355631-how-do-i-program-message-box-yes-no-buttons.html)

DeJon

How do I program a message box with a (Yes),( No) buttons
 
How do I write an instruction in VB to generate a message box that askes for
a yes or no response?

Paul B

How do I program a message box with a (Yes),( No) buttons
 
DeJon, here is one way,

Sub Message_box_test()

Msg = "Put message here"
Title = "Put title here"
Response = MsgBox(Msg, vbYesNoCancel + vbQuestion, Title)

If Response = vbNo Then
'your code if no is clicked here
MsgBox "you clicked no"
Exit Sub ' Quit the macro
End If

If Response = vbCancel Then
'your code if Cancel is clicked here
MsgBox "You clicked cancelled"
Exit Sub ' Quit the macro
End If

'your code if Yes is clicked here
MsgBox "you clicked yes"
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"DeJon" wrote in message
...
How do I write an instruction in VB to generate a message box that askes

for
a yes or no response?




davesexcel[_57_]

How do I program a message box with a (Yes),( No) buttons
 

Here's a site for message boxes
http://www.excel-vba.com/vba-excel-message-box.htm


--
davesexcel
------------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=520900



All times are GMT +1. The time now is 10:26 PM.

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