PDA

View Full Version : VBA synchronous or asynchronous



jungix
07-27-2006, 07:46 AM
The topic on the difference between the Run and Call methods raised my interest to this question, especially now that I am working on real time internet-retrieving data.

Here is my issue. Im my code I retrieve data from the internet thanks to an add-in, and then I have to do other operations depending on the downloaded data. When I open the excel worksheet with the formula enabling me to retrieve the data, it takes some time, and before I get figures the cell as the value #N/A.

So in my macro, after giving the formulas to the cells, I put a sleep 3000 to wait to get the data in a loop until the data was good (<> #N/A). But it didn't work (infinite loop). When I did not use the loop (just computed the cells with the automatic .Calculate method of my worksheet the data was actually downloaded before going to the sequel of the code (and apparently more quickly). I won't coplain that now it seems to work, but I'd like to understand why to be sure not to have bad surprises in the future.