VBA - stopping a macro from running via keypress

zsemle

New Member
Joined
Mar 9, 2022
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hello everyone!
I have a userform which takes around 1,5 hrs to run. I press a button and then the timer starts. (It handles thousands of columns and rows, I am working on optimizing it, but still something like this would be user friendly) I want to be able to stop it at any given time by pressing a button eg.: escape or enter etc.
I have never tried anything like this before, and after searching a lot didn't find any similar questions to mine.
Is there any way something like this can be made?
Pressing escape or ctrl+pause/break doesn't work at all, because the program is already so slow.
A solution is of course ctrl+alt+del, but it is not very subtle.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Stopping it would be an option too, just halting the run time and then the user would be able to close the program.
 
Upvote 0

Forum statistics

Threads
1,216,765
Messages
6,132,586
Members
449,737
Latest member
naes

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