Autorun a macro at preset times

D

Darren

I have a macro that draws data from a website and places in to several tables
which are then organised is different criteria. Instead of me manually
hitting the button with assigned macro, I want to have the macro run itself
every 10 minutes. How do I do this please?
 
M

Mike H

Darren,

have a look at ONTIME in Excel VBA help

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
R

Ryan H

You can use this line of code:

Sub YourSub()

' your code here

Application.OnTime Now + TimeValue("00:10:00"), "YourSub"

End Sub

I would also suggest you reading Chip Pearson's site about the OnTime Event.
Hope this helps! If so, let me know, click "YES" below.

http://www.cpearson.com/Excel/OnTime.aspx
 
D

Darren

Hi Mike, I did as you suggested and this is what I come up with:
Sub Autorun()
'
' Autorun Macro
'

'
Application.OnTime Now + TimeValue("00:10:00"), "Refresh"
End Sub
Unfortunately it only repeats once. How to I make it repeat itself at the
stated time intervals i.e. every 10 minutes?
 
R

Ryan H

You are telling the OnTime Event to run a macro named "Refresh" you want to
re-run "Autorun". Try this line below or see my reply to your original post.
Hope this helps! If so, let me know click "YES" below.

Application.OnTime Now + TimeValue("00:10:00"), "Autorun"
 

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