Question : Geting a vbYesNo MsgBox to call a macro

I should know this by now, but I don't, so here goes again. How do I write this so that upon selecting 'yes', my macro exceutes, and if I select 'no' then I exit the sub?

Thanks,
John
Code Snippet:
1:
2:
3:
4:
Sub MsgBoxTester()
MsgBox "Do you want to run Macro1", vbYesNo, "Run Macro1?"
If yes Then Call Macro1
End Sub

Answer : Geting a vbYesNo MsgBox to call a macro

Hi John,

HainKurt's suggestion appears to be VB.Net, not VBA. teylyn's is workable, but I would suggest declaring all variables, or doing it like this....

    Sub MsgBoxTester()
        If MsgBox("Do you want to run Macro1", vbYesNo, "Run Macro1?") = vbYes Then
            Call Macro1
        End If
    End Sub

Wayne
Random Solutions  
 
programming4us programming4us