Cancel does not work in a sub - Can sb help please?

Ritzl

New Member
Joined
May 16, 2015
Messages
16
Hi all,
I have a small user form which shoes a countdown in seconds, then it closes and goes back to the main Routine and executes some staff (this repeates several times). Now my propblem, I have a cancel button on the form but I can not press it, resp. nothing happens, any idea why. I want to achieve that the cancel button aborts the countdown, closes the user form and goes back to the main program:

Code:
Private Sub CancelBtn_Click()
                                                    '  MsgBox ("Exit procedure cancel Btn....")
        CancelBtn = True
        Me.Hide
End Sub


Private Sub UserForm_Activate()
  For iz = 1 To interval
    Label2.Caption = interval - iz
     If WaitingTime.CancelBtn Then                   ' MsgBox ("Exit procedure....")
         iz = interval - iz
         Unload Me
     End If
     Application.Wait (Now + #12:00:01 AM#)
     WaitingTime.Repaint
  Next iz
    Unload Me
End Sub

Thank you very much for your help ! Cheers Marc
 
Last edited by a moderator:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Are you sure the name of the button is correct? Also, why are you setting the value of the button to True in it's click event? You shouldn't do that.
 
Upvote 0
Hi Thx for answering
Yes, the Name in the properties is CancelBtn

The Problem is, that if im press the CommandButton (Cancel), nothing happens. I tried with a msgBox but it was never showed so it seems the button is not active. Any ideas why that could be?
(I put the msg box as comment so you can see where it was)
Thx Marc
 
Upvote 0
Either that isn't the correct name or the code is not rated by the user form code module.
 
Upvote 0
Either that isn't the correct name or the code is not rated by the user form code module.

Is the a way to send you a print screen about the properties or the whole code? What do you mean by" the code is not rated by the user form..." anything I can do?
my email: ritzl@hispeed.ch
 
Upvote 0
Sorry that was phone autocorrect. I meant the code is not contained in the user form code module.
 
Upvote 0
Hi Rory, sorry was a few days away....I am new to VBA and do not understand what to do. Would you be so kind to show my step by step what I need to do ? would you mind if I email you my file...this might be easier. (I stated my email above in an earlier thread). thx in advance...kind regards Marc
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,166
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top