Reputation: 431
I'm trying to figure out how to use time delays in Excel VBA.
Here's what I want to do:
I have a button in macro that when I click it, it sends the first email. Then after 1 hour, I want to automatically send the second email without clicking another button or running the program again.
I have this code that will set the time. Then after the time expires, it will run the macro. What I want do is to automatically send the second email in an hour after the first send off.
Private Sub Workbook_Open()
Dim sSetTimer As Date
sSetTimer = Sheets("SetTime").Cells(1, 1)
Application.OnTime TimeValue(sSetTimer), "Orayt"
End Sub
Upvotes: 1
Views: 552
Reputation:
Add an hour to the first time and use it to launch a secondary process.
Application.OnTime TimeValue(sSetTimer), "Orayt"
Application.OnTime TimeValue(sSetTimer) + TimeSerial(0, 1, 0), "Orayt2"
Upvotes: 3