Cancel Button

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

I have a Macro with an initial warning in the form of an
OkCancel MsgBox. On 'Ok' I want the macro to continue,
and on 'Cancel' I want it to stop entirely. When 'Cancel'
is pressed the macro does not stop. What am I missing?
Thanks.
 
Try this Matt

Sub test()
Dim Answer As String
Answer = MsgBox("Hi", vbOKCancel, "Title")
If Answer = vbOK Then
MsgBox "run the macro"
Else
MsgBox "By"
End If
End Sub
 
Matt,

Is your code like this

If ans = vbCancel Then
'quit code
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Forgot the first bit

ans = MsgBox ("Hello",vbOKCancel)

then the rest.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top