I am trying to set up a macro to go off at a certain time, when I am not at my desk. I was messing around with the following
Sub timer()
TARGET = #5:39:00 PM#
Do Until Format(Time, "h:m"
= #5:40:00 PM#
If Format(Time, "h:m"
= Format(TARGET, "H:M"
Then
Sheets("Sheet1"
.Select
ActiveCell.FormulaR1C1 = "THE TIME IS NOW " & (Format(Time, "h:m"
Exit Do
End If
Loop
End Sub
My only problem is that the "Do until" command needs to be later than the if statement or it ends. How do I add a minute to the target time in my "Do Until" statement? It would save me from entering the time multiple times. I tried the following, but got errors.
Do Until Format(Time, "h:m"
= (Time, "h:m"
+ TimeValue("00:01:00"
)
By the way, I am not very experienced with VB. Is there an easier, more efficient way to do this. I kind of just came up with it by reading help menus.
Sub timer()
TARGET = #5:39:00 PM#
Do Until Format(Time, "h:m"
If Format(Time, "h:m"
Sheets("Sheet1"
ActiveCell.FormulaR1C1 = "THE TIME IS NOW " & (Format(Time, "h:m"
Exit Do
End If
Loop
End Sub
My only problem is that the "Do until" command needs to be later than the if statement or it ends. How do I add a minute to the target time in my "Do Until" statement? It would save me from entering the time multiple times. I tried the following, but got errors.
Do Until Format(Time, "h:m"
By the way, I am not very experienced with VB. Is there an easier, more efficient way to do this. I kind of just came up with it by reading help menus.