Run Macro Based On Time

S

Sabosis

Hello-

I have a workbook that send out department stats out every hour to our
management team. I need to add something (might be an IF statement) to
run a seperate code if two conditions exist:

The computer time is 9:05

The value of cell a6 is <0.03

If those conditions exist I would need to call a macro named
SendStats3, a special macro that will alert our department admin via
email that we need additional reporting done.

I looked into the Application.ontime function but could not see how to
apply it. Also, does it matter what the "seconds" are on the computer
time? I did not want the computer time to need to be exact down to the
second, just as long as the clock on the PC says 9:05.

Thanks in advance for any help that you might offer up.

Scott
 
S

ShaneDevenshire

Hi,

You need the OnTime command, since you didn't show us your current code you
would need something like this:

This example runs my_Procedure at 5 P.M.

Application.OnTime TimeValue("17:00:00"), "my_Procedure"

within the sub my_procedure you would have your other condition.
 
S

Sabosis

Hi,

You need the OnTime command, since you didn't show us your current code you
would need something like this:

This example runs my_Procedure at 5 P.M.

Application.OnTime TimeValue("17:00:00"), "my_Procedure"

within the sub my_procedure you would have your other condition.

--
Thanks,
Shane Devenshire












- Show quoted text -

What if the time was not exactly at 5:00? My code starts running at
9:05 in the morning, but there is a lot of formatting that takes place
prior to getting to the point where the workbook is emailed out. Does
the Application.Ontime code need to be specific down to the seconds?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top