Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Cancel Button

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Cancel Button

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


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Matt" wrote in message ...
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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Cancel Button

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)

"Matt" wrote in message
...
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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Cancel Button

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)

"Bob Phillips" wrote in message
...
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)

"Matt" wrote in message
...
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.





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
message box without ok or cancel button Subash Excel Discussion (Misc queries) 1 October 18th 05 10:38 AM
Input Box Cancel Button rickylee Excel Programming 2 January 6th 04 11:43 PM
Cancel button in Inputbox method MiRa Excel Programming 2 November 14th 03 01:04 PM
input box cancel button Ian Mangelsdorf Excel Programming 1 August 28th 03 09:05 PM
Button To Cancel Macro Bill Lunney Excel Programming 0 July 16th 03 10:27 PM


All times are GMT +1. The time now is 07:26 AM.

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

About Us

"It's about Microsoft Excel"