Auto Refresh every 3 minutes using a macro

mleiman

New Member
Joined
Jun 20, 2006
Messages
8
I have inserted a button to allow me to refresh my data (Various info from the web), however the data will only refresh when I click the button. Is there a way to make it auto refresh every 3 minutes?

Below is the data from visual basic:

Sub Refresh()
'
' Refresh Macro
'

'
ActiveWorkbook.RefreshAll
Range("B1").Select
End Sub



Thanks for the help
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Below is what I have in my Macro: Still doesn't work......HELP!!!!


Sub Refresh()
'
' Refresh Macro
'


ActiveWorkbook.RefreshAll
Range("B1").Select
End Sub

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 3, CRunIntervalSeconds)
Applicatoin.OnTime EarliestTime=RunWhen, Procedure=cRunWhat,
Schedule = True
End Sub



Thanks
 
Upvote 0
Did you follow the steps on Chip's site? You need to define variables in the declarations section of your module (ie at the top before the macro code and this needs to be in standard module not the ThisWorkbook or a Worksheet module). Also, I noticed in your sub you had a typo:

Rich (BB code):
Applicatoin.OnTime EarliestTime=RunWhen, Procedure="Refresh",
Schedule = True

and also that you should have defined RunWhen as:

Rich (BB code):
RunWhen = Now + TimeSerial(0, 3, 0)

to call the macro a subsequent time, you need to call the StartTimer macro from within your other sub:

Rich (BB code):
Sub Refresh()
'
' Refresh Macro
'


ActiveWorkbook.RefreshAll
Range("B1").Select
 
StartTimer
End Sub

which is why you need to have defined RunWhen as a public variable ie at the top of your module:

Rich (BB code):
Public RunWhen As Variant
 
Upvote 0
is this what you mean? The Applicatoin.Ontime is some how incorrect b/c it shows up in red...

Sub Refresh()
'RunWhen = Now + TimeSerial(0, 3, 0)
Application.OnTime EarliestTime=RunWhen, Procedure=cRunWhat,
Schedule = True
' Refresh Macro
'


ActiveWorkbook.RefreshAll
Range("B1").Select

StartTimer
End Sub

Thanks again
 
Upvote 0
I have attempted to follow the directions on http://www.cpearson.com/excel/OnTime.aspx

However due to my elementry excel skills, i am not able to follow.

Below is the macro I have set up, not sure what/where to type necessary data to make macro reset every three minutes. All help appreciated.

Sub Refresh()
'
' Refresh Macro
'

'
ActiveWorkbook.RefreshAll
Range("B1").Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,553
Messages
6,120,182
Members
448,948
Latest member
spamiki

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top