+ Reply to Thread
Results 1 to 7 of 7

Remove long running loop with someting more efficient

  1. #1
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Red face Remove long running loop with someting more efficient

    Hi... I'm trying to make my spreadsheets run more efficiently, and the first goal I have is replacing as many loops as I can with smarter code. Since I'm neither a programmer, nor all that bright, I'm anticipating some challenges doing so. But since I have more than 20 spreadsheets, each of which can be up to 1 million lines, the loops just aren't cutting it and I'd like to do it better.

    So, the question is, how can I replace something like the code below, which loops through column H and if the active cell contains the value "XXX", the value from 2 columns to the left (F) are copied over?

    Please Login or Register  to view this content.
    I've tried using filters, but I can't seem to get to ONLY the visible cells - so I kind of gave up on that approach.

    Thanks for any guidance!
    Last edited by JP Romano; 09-10-2009 at 01:40 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Remove long running loop with someting more efficient

    Try
    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

  3. #3
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Remove long running loop with someting more efficient

    Thank you Roy - but I'm not sure I fully understand the response. Sorry to be thick skulled, but won't that just set lastcl to equal the last cell in my range? I still have to loop through all the values to replace XXX, right?

    Thanks again

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Remove long running loop with someting more efficient

    Sorry misread the code
    Please Login or Register  to view this content.
    Last edited by royUK; 09-10-2009 at 01:43 PM.

  5. #5
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Remove long running loop with someting more efficient

    Wow... WOW...

    Did I mention, WOW?


    Thank you!

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Remove long running loop with someting more efficient

    That worked then!

  7. #7
    Forum Contributor JP Romano's Avatar
    Join Date
    10-09-2008
    Location
    Princeton, NJ
    MS-Off Ver
    2010
    Posts
    500

    Re: Remove long running loop with someting more efficient

    Sure did... cut down my sample from about 30 minutes to about 5 seconds.
    So, of course, I took credit for it here at work. Getting a promotion and a raise, probably starting me off on a path to senior management, board of directors and ultimately, leisurely weekends on a yacht with (or without) the wife and kids.

    I'm still amazed at how well that worked. Thank you so much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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