Article ID: 142142
Article Last Modified on 10/11/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.
tell me about a message box
msgbox
163435 VBA: Programming Resources for Visual Basic for Applications
Additional query words: 5.00a 5.00c 8.00 XL97 XL7 XL5
Keywords: kbhowto kbprogramming kbdtacode KB142142