Message Box Prompt

G

Guest

I have a code running behind a button which, once pressed, saves the workbook
in a specified directory. Now, I want to give the users the option to cancel
the action.

Therefore, I want a message box that tells the users that if they click on
"OK", the file will be saved in a particular directory, but if they don't
want the file getting saved, they should press "CANCEL".

I want to create a message box which does the following:

If user clicks "OK", the workbook closes.

If user clicks "Cancel", the workbook remains open.

How can I code this?

Thanks, in advance, for your help.

-Yasser
 
B

Bob Phillips

If MsgBox("OK To Save",vbOKCancel) = vbOK Then
Activeworkbook.Close
End If

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

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