Break code

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
How do you stop code running in VBA

I created a loop, but forgot to put in the line that add to the variable, so it's just infinitely looping the same thing over and over again, and has gone unresponsive.

Is there a way to cancel the code from running, because I have not saved things for a little while
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
You definitely want to do it the way Peter describes since that won't close Excel and you shouldn't lose any work. However, if you simply cannot get Excel to break by hitting Ctrl+Pause/Break, then hit Ctrl+Shift+Esc and you'll call up the Windows Task Manager. On the applications tab you can find and end the Excel application. You'll lose any unsaved workbooks, so it's a method of last resort.
 
Upvote 0
Yeah, had to go down the end task route. Luckily Excel recovered most of it, so I only lost about 15 minutes work
 
Upvote 0
Don't feel bad. It's a best practice to put infinite loop protections in any loop structure - something all experienced programmers know. Yet even some of us old timers sometimes forget to do it every once in a while.
 
Upvote 0

Forum statistics

Threads
1,224,519
Messages
6,179,263
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top