Yes / No Msgbox for macro VBA


To put a “yes/no” question before running a macro (with “no” exiting the macro), just put this at the top:

    Dim strName As String
    'InputBox
    strName = MsgBox("Are you sure?", vbYesNo)
    'Exit sub if Cancel button used or no text entered
    If strName = vbNo Then Exit Sub
    'Your code here