JeffGrant
Well-known Member
- Joined
- Apr 7, 2021
- Messages
- 558
- Office Version
- 365
- Platform
- Windows
Hi All,
I am trying to loop the Applicaton.OnTime method through multiple values in a sheet.
The aim is to set up multiple Application.OnTime events.
The variable times are downloaded from a third party site and are being read in from cells so they can't be hard coded.
The OnTime's are firing off ok and with the right formats, however, only the last StartTime is being displayed in the msgbox because that is the last StartTime that has been created.
I assume that I should be using an array structure to create a StartTime variable and then pass that variable to the msgbox. But arrays are not my strong suit.
Much appreciated if someone can point me in the right syntax direction.
Cheers
I am trying to loop the Applicaton.OnTime method through multiple values in a sheet.
The aim is to set up multiple Application.OnTime events.
The variable times are downloaded from a third party site and are being read in from cells so they can't be hard coded.
The OnTime's are firing off ok and with the right formats, however, only the last StartTime is being displayed in the msgbox because that is the last StartTime that has been created.
I assume that I should be using an array structure to create a StartTime variable and then pass that variable to the msgbox. But arrays are not my strong suit.
Much appreciated if someone can point me in the right syntax direction.
Cheers
VBA Code:
Sub Time_Value_Message_Box()
Dim StartTime As Date
For ii = 1 To 3
StartTime = Sheet10.Range("A" & ii).Value
Application.OnTime StartTime, "Time_Value_MSG"
Next ii
End Sub
Sub Time_Value_MSG()
MsgBox "Current Start Time is: " & StartTime
End Sub