cancel ESC key

white_flag

Active Member
Joined
Mar 17, 2010
Messages
331
Hello

I have an macro that will make some calculation on entire workbook. But take some time till finish the calculation (around 3 sec). If I hit the ESC key in this time I have an window with code execution was been interrupted >> Continue ..etc.

I like to tell to excel, wen the macro start, to do not stop wen the ESC key has been press (to give that message)

I putted like this but it is not working:

Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range) 
    Application.OnKey "{ESC}", "NoChange" 
    If Sh.Name = "Calculation" Then Worksheet_Calculate 
End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try like this

Code:
Application.EnableCancelKey = xlDisabled
'
'your code
'
Application.EnableCancelKey = xlInterrupt
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,843
Members
452,948
Latest member
UsmanAli786

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