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

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?
 
G

Guest

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
 
D

Dave Peterson

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.
 
C

Chris

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top