VBA Message Box Yes or No MsgBoxCode for calling a message box with the option Yes or No and depending on the answer different coding is executed.
ExplanationTo call a message box with the option Yes or No and depending on the answer different execute different sub programs is good when trying a more interactive approach with the end-user. By using this function you can choose path of the rest of the program if the user answers yes then a certain code is run and if the user answers no another code is run. Simple and clever! The VBA Macro Code is available for download at the end of this web page!
CodePublic Sub MessageBoxYesOrNoMsgBox()
Dim YesOrNoAnswerToMessageBox As String Dim QuestionToMessageBox As String
QuestionToMessageBox = "Are you an expert of VBA?"
YesOrNoAnswerToMessageBox = MsgBox(QuestionToMessageBox, vbYesNo, "VBA Expert or Not")
If YesOrNoAnswerToMessageBox = vbNo Then MsgBox "Learn more VBA!" Else MsgBox "Congratulations!" End If
End Sub
Download excel file! VBA_Message_Box_Yes_or_No_MsgBox.xls |
Heaven