Hi mrhzoer
You want the code amending so that the value will always be shown in A2, and rather than the time being shown, it is a number that increments by 1 every 5 seconds? If that's the case, does thiw work OK for you? Just bear in mind that before you run it you'll have to change the format of cell A2 from Time to something else - General or Number would be fine. the code could benefit from other tidying up, but we'll stick with the basics first :
Dim icount As Integer, inumberofcalls As Integer
Sub StartOnTime()
icount = 0
inumberofcalls = 4
Range("A1" & inumberofcalls + 1).Select
Range("A1").Select
ActiveCell.Value = "Time"
Call OnTimeMacro
End Sub
Sub OnTimeMacro()
If icount <= inumberofcalls Then
Application.OnTime Now + TimeValue("00:00:05"), "RunEvery5seconds"
icount = icount + 1
Else
Exit Sub
End If
End Sub
Sub RunEvery5seconds()
Range("A2").Value = icount
Call OnTimeMacro
End Sub
HTH
DominicB
Bookmarks