Learn how to create Yes/No/Cancel Message Box in Excel in VBA (also showing how to get the result (response) from Yes/No/Cancel MsgBox).
The code used in this video:
Sub Button1_Click()
'MsgBox - Buttons
'************************************
'Constant Value Description
'vbOKOnly 0 Display OK button only.
'vbOKCancel 1 Display OK and Cancel buttons.
'vbAbortRetryIgnore 2 Display Abort, Retry, and Ignore buttons.
'vbYesNoCancel 3 Display Yes, No, and Cancel buttons.
'vbYesNo 4 Display Yes and No buttons.
'vbRetryCancel 5 Display Retry and Cancel buttons.
'MsgBox - Icons
'************************************
'Constant Value Description
'vbCritical 16 Display Critical Message icon.
'vbQuestion 32 Display Warning Query icon.
'vbExclamation 48 Display Warning Message icon.
'vbInformation 64 Display Information Message icon.
'MsgBox - Response Codes
'************************************
'Constant Value Description
'vbOK 1 OK
'vbCancel 2 Cancel
'vbAbort 3 Abort
'vbRetry 4 Retry
'vbIgnore 5 Ignore
'vbYes 6 Yes
'vbNo 7 No
'************************************
MsgBox "Test Message", vbYesNoCancel
MsgBox "Test Message", vbYesNoCancel, "Test Title"
MsgBox "Test Message", vbYesNoCancel + vbQuestion + vbDefaultButton3, "Test Title"
Dim iResponse As Integer
iResponse = MsgBox("Test Message", vbYesNoCancel + vbQuestion + vbDefaultButton3, "Test Title")
Select Case iResponse
Case vbYes
MsgBox "Yes selected"
Case vbNo
MsgBox "No selected"
Case vbCancel
MsgBox "Cancel selected"
End Select
End Sub
Watch video Excel UserForm MsgBox #7 - Yes/No/Cancel Message Box (VBA) online without registration, duration hours minute second in high quality. This video was added by user InAnOffice 16 February 2014, don't forget to share it with your friends and acquaintances, it has been viewed on our site 9,810 once and liked it 28 people.