Help incorporating Cancel button into processing dialog

MartinS

Active Member
Joined
Jun 17, 2003
Messages
489
Office Version
  1. 365
Platform
  1. Windows
I have been asked to integrate a Cancel button into a processing dialog which displays each process in a running list (see http://www.mrexcel.com/forum/excel-questions/798110-scrolling-label-text.html) as the code progresses.
I added a CommandButton and set it's Cancel property to True (tried it set to both True and False).
I added a public variable definition:
Code:
Public Cancel As Boolean
The code behind the button click event is:
Code:
Private Sub cmdCancel_Click()
Cancel = True
End Sub
When the processing userform is loaded the variable value is set to False.
During the userform's activate code, I check the value and handle appropriately, but it doesn't seem to accept clicks to the button.
Code:
If Cancel Then GoTo SkipProcess
What am I missing? Or is this approach just not possible?
Thanks in advance
Martin
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
The code I attach to my Cancel buttons looks like this:
Code:
Private Sub CancelButton_Click()
    Me.Hide
    Unload Me
End Sub

Hope this helps

Pete
 
Upvote 0
The code I attach to my Cancel buttons looks like this:
Code:
Private Sub CancelButton_Click()
    Me.Hide
    Unload Me
End Sub

Hope this helps

Pete

Hi Pete
Thanks, but my issue is that the Cancel button doesn't appear to allow the user to click it at all. I've added a breakpoint to the code but it never gets hit. I'm sure my logic is right (I have made a few minor changes - the cancel variable is now a userform property instead of a global variable and is reset to False in the code which is jumped to (SkipProcess)), but still the cancel button will not accept mouse clicks!
Thanks
Martin
 
Upvote 0

Forum statistics

Threads
1,221,121
Messages
6,158,060
Members
451,460
Latest member
DanielleS

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