Is there an "On Break" similar to "On Error"?

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I know Excel has an "On Error" function, but is there such a thing as
On Break or On Reset or On Quit or something of that sort? My code
changes Excel's Calculation to Manual and changes it back to Automatic
at the end. There's also an On Error function that changes it back to
Automatic if there's an error in the code.

But sometimes I step through my code and hit Reset, and in this case
the Calculation stays in Manual mode. Is there a way I can change it
back to Automatic when I hit Ctrl+Break or Reset?
 
No, but you can execute the command from the Immediate window.. i.e., enter
this in the command window and then press enter

application.Calculation=xlCalculationAutomatic
 
You can have your code look for a ctrl-break.

Check out
application.EnableCancelKey
in VBA's help.

This won't help you if you hit the Reset button, though.
 
No, but you can execute the command from the Immediate window.. i.e., enter
this in the command window and then press enter

application.Calculation=xlCalculationAutomatic

Thanks for the help, guys. I think I'll take Vergel's advice and
create a comment stating that if the code doesn't run all the way
through, run <application.Calculation=xlCalculationAutomatic> in the
Immediate window. It's crude, but it should get the job done.
 
Back
Top