Hello,
I am using application.onTime to schedule tasks within Excel throughout the day, and the EarliestTime Arguments are coming from defined ranges in Excel such as [Time1] and [Time2]. I wrote the code in this way:
Sub NewTaskScheduler()
Application.onTime earliesttime:=[Time1], procedure:="FirstCode"
Application.onTime earliesttime:=[Time2], procedure:="SecondCode"
End Sub
Sub FirstCode()
'Do Something1
End Sub
Sub SecondCode()
'Do Something2
End Sub
Instead of writing individual Subs for FirstCode, SecondCode etc, which will end up being a long list, I would like to group them all into a Generic Sub like that:
Sub NewTaskScheduler()
Application.onTime earliesttime:=[Time1], procedure:="GenericCode"
Application.onTime earliesttime:=[Time2], procedure:="GenericCode"
End Sub
Sub GenericCode()
If EarliestTime = [Time1] Then DoSomething1
If EarliestTime = [Time2] Then DoSomething2
End Sub
Or Even better, since my DoSomething are quite simple, such as [A1]=1, the best would be:
Sub NewTaskScheduler()
Application.onTime earliesttime:=[Time1], procedure:=[A1]=1
Application.onTime earliesttime:=[Time2], procedure:=[A2]=2
End Sub
Especially on that last option, is there a way to do that?
Thank you for the help.
I am using application.onTime to schedule tasks within Excel throughout the day, and the EarliestTime Arguments are coming from defined ranges in Excel such as [Time1] and [Time2]. I wrote the code in this way:
Sub NewTaskScheduler()
Application.onTime earliesttime:=[Time1], procedure:="FirstCode"
Application.onTime earliesttime:=[Time2], procedure:="SecondCode"
End Sub
Sub FirstCode()
'Do Something1
End Sub
Sub SecondCode()
'Do Something2
End Sub
Instead of writing individual Subs for FirstCode, SecondCode etc, which will end up being a long list, I would like to group them all into a Generic Sub like that:
Sub NewTaskScheduler()
Application.onTime earliesttime:=[Time1], procedure:="GenericCode"
Application.onTime earliesttime:=[Time2], procedure:="GenericCode"
End Sub
Sub GenericCode()
If EarliestTime = [Time1] Then DoSomething1
If EarliestTime = [Time2] Then DoSomething2
End Sub
Or Even better, since my DoSomething are quite simple, such as [A1]=1, the best would be:
Sub NewTaskScheduler()
Application.onTime earliesttime:=[Time1], procedure:=[A1]=1
Application.onTime earliesttime:=[Time2], procedure:=[A2]=2
End Sub
Especially on that last option, is there a way to do that?
Thank you for the help.