PDA

View Full Version : the macro will stop automatically when the time it spent exceeds 3 minutes



clarksonneo
10-09-2011, 01:54 AM
Hi,

Is it possible to create a macro which can perform the following function?


Function:

I want the macro will stop automatically when the time it spent exceeds 3 minutes.

If a macro needs to handle, says, 100000 rows of data, the macro may need to spend over 5 minutes to complete its work.



Thanks

Bob Phillips
10-09-2011, 03:23 AM
I guess you would have to check a timer in your loop, something like



Dim nTime As Double
Dim i As Long

nTime = Timer

For i = 1 To 1000000000

If Timer - nTime > 5 Then 'secs

Exit Function
End If
Next i