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
Смотрите видео Excel UserForm MsgBox #7 - Yes/No/Cancel Message Box (VBA) онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь InAnOffice 16 Февраль 2014, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 9,810 раз и оно понравилось 28 людям.