Macro which keeps running

anuragit13

New Member
Joined
Mar 22, 2018
Messages
17
I need a macro which keeps running at the backend...whether I do anything on system or not, it should perform some activity in excel till the time I want.

I need a button that starts that macro and when I want to stop that then i press again a button to stop the macro.
Please help.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
it's not possible as you want, because once a button sets off a macro the macro will run until either something in the macro stops it or you hit Escape or Control-break; clicking on another button will be ignored.

A simple macro would be

Code:
Sub RunCode
Do While True
    DoEvents
Loop
End Sub

With a normal macro once it starts running it will ignore anything clicked or typed except the Escape key or Control-Break key.

You need the DoEvents or the loop will run so fast it never recognises the Escape or Ctrl-Break.

Either way you might have to sit with your finger on the Escape key for a long time or keep hitting Ctrl-Break.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,139
Messages
6,123,262
Members
449,093
Latest member
Vincent Khandagale

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