set code to go off every x seconds

TiTuS

Board Regular
Joined
Nov 10, 2004
Messages
238
Hi, just working on a code but need to be able to get it to trigure itself every 5-10 seconds... is this possible?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Can you explain a little bit what you are trying to do? Will you be continuing to work on your machine during this time? Will there be other applications running also? If you tie up the CPU with this process, is that a problem? Good Luck!
 
Upvote 0
nah no problem if it ties up machine its so it can be going in the background, i may use a internet browser sometimes but it dosnt matter to much how many resources it uses... i know you cant do much while its going :) its so that i can leave a sheet refreshing so that if data changes on a site then it records the exact time it happened so while im away from keyboard i can open it and leave it monitoring :)
 
Upvote 0
If the source of your data is from a web site and you've used the Website import wizard found on the Data toolbar then the refresh time is a built in property of the import.
Eg. Once you've set up your import data sheet just "right click" on sheet and select "Data Range Properties" from the drop down menu. In the "properties window you can set how ofter you want the refresh to occur.
 
Upvote 0
only problem is it only goes down to 1 minute, im wanting under a minute updates
 
Upvote 0
If the 1 minute refresh is to long then here's some code that will do the trick... however it will tie up that particular instance of the excel app. :eek:

the following example refreshes web info on Sheet1

Sub LoopRefresh()
StartHere:
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

With ThisWorkbook.Sheets("Sheet1").Cells
.QueryTable.Refresh BackgroundQuery:=False
End With

GoTo StartHere
End Sub

:eek: NOTE : TO TERMINATE CODE PRESS CTRL+ ALT + BREAK :eek:


PS.... The wait code is directly from the VBEditors help file....

Wait Method Example

This example pauses a running macro until 6:23 P.M. today.

Application.Wait "18:23:00"
This example pauses a running macro for approximately 10 seconds.

newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
This example displays a message indicating whether 10 seconds have passed.

If Application.Wait(Now + TimeValue("0:00:10")) Then
MsgBox "Time expired"
End If
 
Upvote 0
Thankyou so much! thats exactly what i needed.. and thankyou very much for showing me steps now i can see how its done and next time be able to :)
 
Upvote 0

Forum statistics

Threads
1,203,619
Messages
6,056,325
Members
444,860
Latest member
Daz511

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