+ Reply to Thread
Results 1 to 8 of 8

Making a simple loop faster

  1. #1
    Registered User
    Join Date
    06-16-2008
    Posts
    32

    Making a simple loop faster

    Ok, here's the code for it
    Please Login or Register  to view this content.
    Basically it makes a loop from 1 to the value in D1, which is the total amount of clients there's in the list.

    and then starting from C23 it adds an increasing number starting from 1 to every 4th row.

    Simple, but painfully slow... Is there some trick to make it faster?

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    The sample you gave works very quick, i don't see what your problem could be unless you are actually adding a formula then it would slow down as the worksheet will calculate for every formula added so you need to set the calulation to manual.
    Not all forums are the same - seek and you shall find

  3. #3
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    loop

    Hi
    What is a typical value in D1 and What is your expected and observed speed?
    Ravi

  4. #4
    Registered User
    Join Date
    06-16-2008
    Posts
    32
    Quote Originally Posted by ravishankar
    Hi
    What is a typical value in D1 and What is your expected and observed speed?
    Ravi
    Right now there's 300-400 in D1

    it takes around ... 30 seconds or so.

    and to Simon, nope there's no formula

    it adds just a number 1, 2 ,3, 4 ,5 and so on.

  5. #5
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Try this see if it makes a difference!
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-16-2008
    Posts
    32
    Quote Originally Posted by Simon Lloyd
    Try this see if it makes a difference!
    Please Login or Register  to view this content.

    Worked like charm, thanks!

  7. #7
    Registered User
    Join Date
    08-23-2008
    Location
    Mundelein,ill
    Posts
    1

    Talking Great trick!

    Used

    Application.Screenupdating=False
    Application.Calculation = xlManual
    'YOUR CODE
    Application.Calculation = xlAutomatic
    Application.Screenupdating=True

    Adding the Application.Calculation to Manual took my run time from 5 minutes to 45 seconds.
    Disabled the screen update as well & took it down to 13 seconds.

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    This doesn't use a loop to get the result
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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