Continuous Do Loop desired, almost

mrdavie007

New Member
Joined
Jul 5, 2011
Messages
6
I am writting several macros the goal of which is to update my worksheets based on new information from the web when it becomes available. I've written the entire update process but I would like this to happen at regular intervals for perhaps days or even up to a week at a time. The problem comes in when I want to stop the loop. I don't want to just stop the code excecution because it may be in the middle of performing an update and stopping in the middle of the process would leave undesired affects on the worksheet. Any ideas on how something like this could be done cleanly (i.e. no Ctrl + Break) would be appreciated. I'm trying to keep things looking proffesional, at least on the external even if the code isn't so pretty.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I am no expert, however, you could put the following script at the start of your macro.

Code:
Application.EnableCancelKey = xlDisabled

You must put the following at the end of your code though, otherwise you will have problems later if you do want to stop code running.

Code:
Application.EnableCancelKey = xlEnabled

Or you can put a value in a cell and if it equals that value then the script would either have the state of enabled or disabled.

Code:
If Range("A1").value = "0" then
Application.EnableCancelKey = xlDisabled
else
Application.EnableCancelKey = xlEnabled
end if
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,881
Members
452,948
Latest member
Dupuhini

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