PDA

View Full Version : [SOLVED] Run a macro at a specific time and day



simora
08-03-2010, 06:11 PM
I'm trying to get this macro to run every Tuesday at 6:02 PM

This is what I have;



Private Sub Workbook_Open()
If Day(Now) = 3 Then
Application.OnTime TimeValue("18:02:00"), "MyMacro"
End If
End Sub

Sub MyMacro()
Application.OnTime TimeValue("18:02:00"), "MyMacro"
MsgBox Now()
End Sub


I tried it for different days and it still doesn't work. Any ideas why it doesn't work. Need help.

Thanks

mbarron
08-03-2010, 07:06 PM
You don't specify in which way it doesn't work. Do you receive an error? Does nothing happen?

Are you putting the second sub into a standard module?

If I put the Workbook_Open routine in the ThisWorkBook module and the second sub in a standard module, I receive the Msgbox at the appointed time.

simora
08-03-2010, 07:35 PM
Nothing happens. I don't get a message box or anything.

mbarron
08-03-2010, 07:51 PM
Do you have the subs in the correct location? Are macros enabled for the workbook? Is the workbook open at 6:02?
The attached file should display the message at 8:02 pm

simora
08-03-2010, 08:03 PM
Yours worked. Still cant figure out why mind didn't.

Thanks