Excel RTD in VBA

1.8k views Asked by At

I am trying to grab RTD output in VBA. The problem is it takes a couple seconds sometimes for the data to come back so when I run a loop half the time it incorrectly returns 0. Apparently RTD is running asynchronously. How can I set it to run synchronously so it waits for a correct output?

If I put the formula in a cell it usually returns instantly sometimes it takes a second. If I try to loop in VBA it goes to the next value too quickly and returns false positives because it is not waiting for the data to return. I have tried RTD.RefreshData and it is not loading fast enough to keep up with my loop. (My goal is to loop through thousands of fields using RTD which is why I need to do this)

1

There are 1 answers

2
Radek On BEST ANSWER

What about waiting in loop for condition to be met:

Do Until Cells(1, 1) <> "" ' use plausible condition
    Application.Wait (Now + TimeValue("0:00:01"))
Loop