View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Paul B Paul B is offline
external usenet poster
 
Posts: 709
Default 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?