Prevent user to stop a calculation

SabCie

New Member
Joined
Dec 20, 2010
Messages
24
Hi a have a big Excel program. The only macro that I use is a button that turns the calculation mode to manual and then makes a "calculate". This takes about 2 min and then it get back to an automatic calculation mode.

The problem is that when it is running and that a user press the "Esc" button, the calculation does not complete.

Is there a way to prevent this?

I have tried to disable the "Application.EnableCancelKey" but It did not worked. Also I tried Application.OnKey "{ESC}", "" but nothing also....

Help would be greatly appreciated.

Thanks!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try

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

I had tried that already but I still can press Esc and the calculation will stop. What is weird is that when I type "Application.EnableCancelKey = xlDisabled" in the immediate window, it returns me a 1 instead of a 0...
 
Upvote 0
I'm surprised. Maybe something like this

Code:
On Error GoTo ErrHandl
Application.EnableCancelKey = xlErrorHandler
'
'your code
'
ErrHandl:
If Application.CalculationState = xlDone Then Application.EnableCancelKey = xlInterrupt
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,432
Members
452,326
Latest member
johnshaji

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