Thread: Macro - msgbox
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Paul B Paul B is offline
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:)