• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Can we trigger a macro on a particular time ?

ThrottleWorks

Excel Ninja
Hi, I have a macro which fetches currency rates from a URL into an excel file.

I have to run this macro on daily basis.


I have a problem, I want to run the macro at a pre-defined time every day so that values can be compared correctly.

Is there any way, that we can trigger the macro at a exact time, this might look silly , but honestly I need to automate this function also.


Any & every help is welcome.
 
Hi Sachin,


Yes, this is done with use of Application.OnTime function. It required, the timevalue and name of calling function.


example

sub Testing

Application.OnTime Now + TimeValue("00:00:30"), "Called_Sub"

end sub


sub Called_Sub

msgbox "I came after 30 seconds

end sub


for your case to run at specified time, do not use "now +" just use timevalue and set the time. The current excel instance should not be closed after that till the event time occurs. Although you may close the file.


Hope this gives you some idea to proceed..


Regards,

Prasad DN
 
Hi Prasad, thanks a lot for the help.

Sorry for late reply....was very busy, so could not reply on time.


Once again thanks very much.
 
Back
Top