Ending a Macro at a specified time

Kourada

New Member
Joined
Apr 8, 2002
Messages
17
How do I get a macro to end after 1 minute of running. The macro was written to run a refresh on a Web Query (excel 2000), but if the macro is searcing for the data for over 1 minute, I would rather it stopped looking, and started all over again.

Thanks
Hios@interaccess.com
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I Understand how to use the NOW and ONTIME functions to start a macro, but how do I use them to stop a macro from running. I think a simple example is all I need to figure it out.

Thanks for the quick response.
 
Upvote 0
Try the following:

Dim StartTime, Duration As Integer
StartTime = Second(Now)
Duration = 3
Do
counter = counter + 1
Loop Until Second(Now) > StartTime + Duration
MsgBox "This macro looped " & counter & " times in " & Duration & " seconds"
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,185
Members
448,554
Latest member
Gleisner2

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