![]() |
Is there an "On Break" similar to "On Error"?
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? |
Is there an "On Break" similar to "On Error"?
Nope... When you interupt the code you need to manually restore the settings.
-- HTH... Jim Thomlinson "Chris" wrote: 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? |
Is there an "On Break" similar to "On Error"?
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 -- Hope that helps. Vergel Adriano "Chris" wrote: 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? |
Is there an "On Break" similar to "On Error"?
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. Chris wrote: 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? -- Dave Peterson |
Is there an "On Break" similar to "On Error"?
On Aug 7, 11:32 am, Vergel Adriano
wrote: 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 -- Hope that helps. Vergel Adriano "Chris" wrote: 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? 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. |
All times are GMT +1. The time now is 12:09 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com