Article ID: 193559
Article Last Modified on 9/12/2006
Sub Msgbox_Yes_No()
Dim Response As Integer
' Displays a message box with the yes and no options.
Response = MsgBox(prompt:="Select 'Yes' or 'No'.", Buttons:=vbYesNo)
' If statement to check if the yes button was selected.
If Response = vbYes Then
MsgBox "You selected 'Yes'."
Else
' The no button was selected.
MsgBox "You selected 'No'."
End If
End Sub
When you run the macro, you receive a message box that contains Yes and No buttons. If you click Yes, the macro displays a message box telling you that you clicked the Yes button. When you click No, a message box appears stating that you clicked the No button.
Additional query words: XL98
Keywords: kbhowto kbdtacode KB193559