#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 23
Default Macro - msgbox

I have a rather large macro, and I want to give the user a chance to exit the
macro before it runs. I need a msgbox (or a dialogue?) with a warning, and
the user will select either OK (to run the defined macro) or cancel (to exit
and not run the macro).

Can anyone help me?

Thanks:)
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 709
Default Macro - msgbox

traima, here is an example of one with an option if yes no and cancel

Sub Message_box_test()

Dim Msg, Title, Response As String

Msg = "Put message here"

Title = "Put title here"

Response = MsgBox(Msg, vbYesNoCancel + vbQuestion, Title)



If Response = vbNo Then

'your code if no is clicked here

MsgBox "you clicked no"

Exit Sub ' Quit the macro

End If



If Response = vbCancel Then

'your code if Cancel is clicked here

MsgBox "You clicked cancelled"

Exit Sub ' Quit the macro

End If



'your code if Yes is clicked here

MsgBox "you clicked yes"

End Sub

"traima" wrote in message
...
I have a rather large macro, and I want to give the user a chance to exit
the
macro before it runs. I need a msgbox (or a dialogue?) with a warning, and
the user will select either OK (to run the defined macro) or cancel (to
exit
and not run the macro).

Can anyone help me?

Thanks:)



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I email amacro? leo Excel Worksheet Functions 24 August 9th 06 02:47 PM
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Hiding, or automatically answering, a confirmation msgbox Brian Beck Excel Discussion (Misc queries) 1 July 28th 06 04:11 PM
link to combobox legepe Excel Discussion (Misc queries) 4 July 26th 06 04:45 PM
Editing a simple macro Connie Martin Excel Worksheet Functions 5 November 29th 05 09:19 PM


All times are GMT +1. The time now is 01:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"