In VBA on Excel, I have a loop over several thousands of cells, which takes some minutes.
Is it possible to abort a long term loop (if so, how) / can I build a button or something like that to interrupt this loop manually?
Building a button and overlaying it with a macro is not a problem, only the code itself.
When Excel is busy executing your macro, it won’t respond to a button.
You have three options here:
Ctrl+Breakkeys (as apposed to a button)Application.ScreenUpdatingtoFalsewill help)much slower by inserting a
DoEventsin the inner loop. Thisway, Excel will resond to buttons in
the meantime. The macro this button would trigger would just set a global variable to
True(obviously, your inner loop should check this variable on each iteration, and exit if it’sTrue).