PDA

View Full Version : Solved: cancel ESC key



white_flag
04-13-2011, 02:27 AM
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:

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

white_flag
04-14-2011, 05:15 AM
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Excel.Range)
Application.EnableCancelKey = xlDisabled
If Sh.Name = "Calculation" Then Worksheet_Calculate
Application.EnableCancelKey = xlInterrupt
End Sub