troubleshooting Question

How do I pause/wait 1 second in Excel VBA?

Avatar of shaolinfunk
shaolinfunkFlag for United States of America asked on
Microsoft ExcelVB Script
5 Comments1 Solution6340 ViewsLast Modified:
I am iterating through a for/next loop where each loops retrieves data from a database and outputs data to a .txt file.  There are about 3000 iterations (for x = 1 to 3000).  

What ends up happening, I think, is that Excel cannot read & write data fast enough to keep up with the for/next loop iterations...and ends up skipping some files and not outputting a .txt file at all.  Thus, I am missing some important data files.  

How can I "slow down" the for/next loop such that it waits 1 full second before moving onto the next iteration?  However, I don't want to "pause" the program because the data will not get read/written/outputted to a .text file if the program is paused.  Basically I want to give the macro time to output data before it moves onto the next iteration.  How do I do this?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros