Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Application.EnableCancelKey = 2
- ?Application.EnableCancelKey
- 1
- Sub Test1()
- Debug.Print " Before execution result : " & Application.EnableCancelKey
- On Error GoTo handleCancel
- Application.EnableCancelKey = 2 'xlErrorHandler
- Debug.Print " Regular execution result : " & Application.EnableCancelKey
- For x = 1 To 10000 ' Do something 1,000,000 times (long!)
- Debug.Print "Test"
- Next x
- handleCancel:
- If Err = 18 Then
- Debug.Print "Aborted macro result : " & Application.EnableCancelKey
- MsgBox "You cancelled"
- End If
- End Sub
- Sub test2()
- On Error GoTo theEnd
- Application.EnableCancelKey = 2
- Debug.Print Application.EnableCancelKey
- theEnd:
- End Sub
Add Comment
Please, Sign In to add comment