Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

continous macros in excel

Status
Not open for further replies.

altaratz

ISP
Apr 15, 2001
73
US
I need a way to run either a data refresh, or a macro about every 1-2 seconds - and I can't think of a way to get it done.

the 'Refresh Data' will only run every 1 minute at the most - can anyone think of a clever way to do this - your help is much appreciated!

Ethan Altaratz
 
This macro will run forever, as long as the activecell value is blank:
Code:
Sub test()
If ActiveCell.Value = "" Then
  call test
End If
End Sub
 
altaratz

You seem to be trying to view something in "real time" using excel. This is going to kill the system resources of whatever PC this macro is run on. There's probably a better way to get what you want...perhaps using links to the source that is being updated?
 
Thanks both of you - actually, the data source doesn't allow for dynamic links, so I'm having to continually refresh from a data file to which the new data is being appended.

The if . . . then statement doesn't seem to be working - it runs once, and then stops - should it be a 'while' statement?

Thanks,

Ethan Altaratz
 
try something like:
Code:
Sub test()
do
call [red]Your_Code_Name[/red]
loop
End Sub
If you'd like to schedule the macro to run periodically rather than have it go through an endless loop, then check out this thread that was posted today:
thread68-834598
 
OK - that worked, but you're right - it was too much.

Here's a brain teaser - is it possible to have excel refresh the data query from "data.txt." only when the test file is updated?

Isn't there some kind of event handler in Windows to do this?

Thanks,

Ethan
 
If the "test file" is data.txt, I think it would be tough. If the test file is in excel, it's not so bad...you could put code in test.xls and put in an "on save" or "on close" procedure that would update the related file out on the network anytime test.xls is saved or closed.

Again, if the source is a text file, I don't know how you could do it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top