ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autorun a macro at preset times (https://www.excelbanter.com/excel-programming/439433-autorun-macro-preset-times.html)

Darren

Autorun a macro at preset times
 
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?

Mike H

Autorun a macro at preset times
 
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.


"Darren" wrote:

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?


Ryan H

Autorun a macro at preset times
 
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

--
Cheers,
Ryan


"Darren" wrote:

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?


Darren

Autorun a macro at preset times
 
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?

"Mike H" wrote:

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.


"Darren" wrote:

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?


Ryan H

Autorun a macro at preset times
 
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"
--
Cheers,
Ryan


"Darren" wrote:

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?

"Mike H" wrote:

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.


"Darren" wrote:

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?


Darren

Autorun a macro at preset times
 
Thankyou.



All times are GMT +1. The time now is 01:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com