I apologize for the confusion. You’re correct; the Application.OnTime method doesn’t provide a direct pause mechanism like Application.Wait. It schedules a procedure to run at a future time but doesn’t pause the code execution.
If you want to achieve a pause between updates, you can use the DoEvents function combined with a timer loop. Here’s a modified version of the code that introduces a pause:
Dim TargetValue As Integer
Dim PauseTime As Double ' Use a double for more precise timing
' Set the initial value, target value, and increment amount
TargetValue = 100 ' Change this to your desired target value
Increment = 1 ' Change this to your desired increment amount
PauseTime = 0.1 ' Change this to your desired pause time in seconds (e.g., 0.1 seconds)
' Loop until the counter reaches the target value
Do While Counter < TargetValue
' Update the cell or display area where you want to show the animated value
' In this example, we'll update cell A1
Range("A1").Value = Counter
' Pause for the specified time
Counter = Counter + Increment
Sub Pause(ByVal Seconds As Double)
Do While Timer < Start + Seconds
DoEvents ' Allow Excel to process other events during the pause
In this modified code, the Pause subroutine introduces a pause for the specified number of seconds using a timer loop and DoEvents. This should provide a similar pause effect as Application.Wait. Adjust the PauseTime variable to control the duration of the pause.