Display warning before running macro

J

Jamie

Is it possible to display a warning message before running
a macro with a command button?
 
J

Jan Karel Pieterse

Hi,

Include this line of code at the top of the macro:

If Msgbox("Are you sure?",vbQuestion+vbYesNo,"Look out!!")
=vbNo Then Exit Sub

Regards,

Jan Karel Pieterse
Excel TA/MVP
 
B

Bernie Deitrick

Jamie,

Sure. Just put this code at the top of your macro.

If MsgBox("Are you SURE you want to run this macro?", _
vbYesNo) = vbNo Then Exit Sub

HTH,
Bernie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top