+ Reply to Thread
Results 1 to 4 of 4

Add delay into Loop in VBA without locking Excel

  1. #1
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    110

    Add delay into Loop in VBA without locking Excel

    Hi Experts,

    I have searched the site and others but I can't seem to find a way to do what I am trying to do.

    - I have a Macro that runs another Program and needs to run one by one down the Excel file.
    - The Macro runs the file fine, but the Program writes back to Excel values that I need for the next run
    - I need the next run to be delayed till the values are written back into the Excel file (I am using a Loop for the repetitive runs)(2 min delay)


    I tried application.wait and others but it locks Excel from writing back. I am not sure how to do the While loop in a loop it keeps giving errors. Any help would be greatly appreciated.

    Do Until LoopCount = 0

    Other Program Stuff

    Delay Needed Here (I think)

    Loop

    MsgBox "All done!"


    Exit Sub

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Add delay into Loop in VBA without locking Excel

    This will delay for a half second. You can use whole or decimal values measured in seconds for your delay times. The DoEvents will allow other events and apps to run while pausing the current macro.
    Please Login or Register  to view this content.
    Last edited by JLGWhiz; 04-25-2018 at 01:44 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  3. #3
    Forum Contributor
    Join Date
    11-08-2012
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Add delay into Loop in VBA without locking Excel

    Thank You JLGWhiz That Worked!

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Add delay into Loop in VBA without locking Excel

    Quote Originally Posted by theglitch View Post
    Thank You JLGWhiz That Worked!
    You're welcome. Don't forget to click Solved.
    regards, JLG

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Time Delay on nth pass through a loop
    By cooper.1651 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-04-2015, 08:49 PM
  2. [SOLVED] Excel Delay in Opening
    By romandotcom in forum Excel General
    Replies: 5
    Last Post: 05-12-2014, 12:55 AM
  3. Loop Macro Locking Up
    By adam1230 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-19-2011, 03:09 PM
  4. Help with macro, automatical locking cells when excel is closed but only locking 1 sh
    By snoopy1461 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-21-2011, 11:29 AM
  5. Excel delay for 1 second
    By mrswiggle in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 10-18-2010, 10:07 AM
  6. A problem implementing a delay within a for-each loop
    By twills in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-19-2009, 02:42 AM
  7. Delay to startup excel spreadsheet
    By Gee in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1