![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 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 |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try using the NOW and ONTIME functions.
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
New Member
Join Date: Apr 2002
Posts: 17
|
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. |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
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"
__________________
Kind regards, Al Chara |
|
|
|
|
|
#5 |
|
New Member
Join Date: Apr 2002
Posts: 17
|
Works Great!
Thanks again for your help. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|