Learn Macros‎ > ‎VBA Macros‎ > ‎

vbYesNo in MsgBox

posted Jan 30, 2011, 5:53 AM by Ayush Jain   [ updated Jan 30, 2011, 5:56 AM by ayushjain@live.com ]
When you want to take any action on the basis of YES or NO selected by user in MsgBox, Use this code

Public Sub YesNo()

    If MsgBox("This macro will ... Do you want to continue?", vbYesNo + vbCritical, "Caution") = vbYes Then
    ' do something
    Else
    ' do something else
    End If

End Sub

Comments