+ Reply to Thread
Results 1 to 6 of 6

Excel uses 100% CPU for 4 hours...

  1. #1
    Registered User
    Join Date
    03-15-2007
    Posts
    17

    Excel uses 100% CPU for 4 hours...

    I have a program that takes 4 hours to run. That's fine sincethere are thousands or rows of data to process so I just let it run overnight.

    But my tripple-nested loop is apparently coded so tightly :-) that Excel allows no breathing room for other processes that might need a little CPU time.

    Is there a command I could put in my inner-most loop that would tell Excel to take a breather for a few thousands of a second. In Unix terms, I would like it to play 'nice'.

    When I programmed in the early Macintosh days, it had a system() function that was considered 'considerate' to put in your loops. System() would allow the Operating "System" some time for housekeeping chores, etc.

    Is there anything like that available in Excel's VBA?

    I realize it would make the program slower and it make take even longer to run.

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    Take a look at the DoEvents() function in VBA help.

    Richard

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    You could insert DoEvents in your loop, or use the Windows Sleep API:
    Please Login or Register  to view this content.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Maybe use sleep
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770
    I think 'DoEvents' will do this for you, best to read and check it though.

  6. #6
    Registered User
    Join Date
    03-15-2007
    Posts
    17
    DoEvents worked great. Thanks guys.

+ 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. Importing Excel worksheet into Word
    By mark87 in forum Excel General
    Replies: 0
    Last Post: 09-08-2008, 12:20 PM
  2. processing a string by Excel
    By mark_neil2 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-20-2007, 07:35 AM
  3. Going insane!
    By kik in forum Excel - New Users/Basics
    Replies: 10
    Last Post: 01-31-2007, 08:21 AM
  4. Excel to Access: Updating records
    By alexwhite in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2006, 10:40 AM

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