I am working with Visual Basic Application on Excel. I have a Macro, which should be executed after a time delay. I want to track the waiting time with a timer meanwhile. I have created an additional module in which I have the following functions:
Public Sub start_time()
Application.OnTime Now + TimeValue("00:00:01"), "next_moment"
End Sub
Public Sub end_time()
Application.OnTime Now + TimeValue("00:00:01"), "next_moment", , False
End Sub
Public Sub next_moment()
If Worksheets("Messwerte").Range("A1").Value = 0 Then Exit Sub
Worksheets("Messwerte").Range("A1").Value = Worksheets("Messwerte").Range("A1").Value - TimeValue("00:00:01")
start_time
End Sub
I have my timer in the cell Worksheets("Messwerte").Range("A1").Value. The structure of my code is now the following:
For Loop
Code Block 1
Call start_time #Waiting should be applied here
Code Block 2
End For Loop
My problem is now that the timer starts at start_time, but Code Block 2 is also starting. I want to have my timer and when my timer shows "00:00:00" then Code Block 2 should start.
On the forums I just found solutions to either having a timer or to wait until the code is continued but not both working like I want to. Does someone has a solution on this?
Thanks