Insert a Warning Msg before running a Macro

B

bnkkn

Okay guys, I have a question for ya,

I wrote a macro that I have programed to a button on my excel
worksheet, we'll call it MacroA.
This macro will change the layout of the worksheet, so I would like to
make sure that the User really did intend to run MacroA and it was not
just a slip of the mouse.
What I would like is a warning message to pop up before MacroA runs.
So quickly let me describe the scenario I would like to happen:

-User inputs the desired data
-User clicks on the button to run Macro A
-A warning message will pop up that will ask "Are you sure you would
like to run MacroA?" (with Ok/ Cancel buttons)
-User clicks "Okay" then MacroA will run
-User clicks "Cancel" then close the warning box.

I took a 2 credit C++ class a few years ago in college, but I never got
to any UI code. A little help would be appreciated...

Thanks,

Ben
 
G

Gary Keramidas

maybe something like this?

Select Case MsgBox("Are you sure you want to continue?", vbYesNo Or vbQuestion _
Or vbDefaultButton1, "Continue?")

Case vbYes
GoTo Cont
Case vbNo
Exit Sub
End Select
Cont:
' your code
 
C

Chip Pearson

In addition to being a programming practice that is universally frowned
upon, the "Goto" in this code is entirely unnecessary.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)
 

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