View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
davegb davegb is offline
external usenet poster
 
Posts: 573
Default userform cancel button

I have a cancel button in a userform. The code in the form unloads the
userform. But I want the cancel button to end the main macro too. I've
tried numerous conbinations of

if cbCancel then exit sub

and a dozen others. None of them work. They either cancel the program
even if the Cancel button isn't clicked, or don't exit when it is. I
did a google search here and found a number of routines, none of which
seemed to apply to my situation (I don't need to check and see if the
person speaks English to exit. I want my users to be able to exit even
if they don't speak English!). Can someone give me some simple code to
put in my macro to close the program if the cbCancel command button has
been clicked?

Thanks for the help!