+ Reply to Thread
Results 1 to 11 of 11

Slow code

  1. #1
    Registered User
    Join Date
    06-15-2015
    Location
    Seattle
    MS-Off Ver
    2013
    Posts
    62

    Slow code

    This code is pretty slow any thoughts on how I can improve it?


    Please Login or Register  to view this content.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Slow code

    The first best thing you could do is to not do a full-column search. Restrict the extents via a dynamic range or otherwise.

    The next best thing is to sort col A, so you don't need to do a linear search.

    Third, why do the search three times?

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,385

    Re: Slow code

    Instead of looping through the range, you would be better determining the last row of interest and dropping each formula into the entire range. The formula will auto adjust. And, if it's a Structured Table, you probably only need to drop the formulae into the first row anyway.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    06-15-2015
    Location
    Seattle
    MS-Off Ver
    2013
    Posts
    62

    Re: Slow code

    Thanks for the help guize I think I got some ideas.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,385

    Re: Slow code

    You're welcome. Thanks for the rep.

  6. #6
    Registered User
    Join Date
    06-15-2015
    Location
    Seattle
    MS-Off Ver
    2013
    Posts
    62

    Re: Slow code

    Had an idea but still have not found an eloquent solution to this. Any thoughts?

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,385

    Re: Slow code

    Suggest you post a sample workbook.

  8. #8
    Registered User
    Join Date
    06-15-2015
    Location
    Seattle
    MS-Off Ver
    2013
    Posts
    62

    Re: Slow code

    Please Login or Register  to view this content.
    This is the new code
    Last edited by saechaoc; 07-21-2015 at 01:56 PM. Reason: Error

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,385

    Re: Slow code

    See post #7

  10. #10
    Registered User
    Join Date
    06-15-2015
    Location
    Seattle
    MS-Off Ver
    2013
    Posts
    62

    Re: Slow code

    Please Login or Register  to view this content.
    If anyone else has thoughts on improving it would love to hear it but this is as efficient as I could get it.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,385

    Re: Slow code

    Down from 12 lines of code to 11 with no loop so looks good to me.

    Regards, TMS

+ 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. Slow code- making code more efficient
    By ammartino44 in forum Excel General
    Replies: 4
    Last Post: 05-06-2015, 12:47 PM
  2. Please Help With Slow VBA Code
    By chrisj4269 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2014, 05:39 AM
  3. Why is this code so slow?
    By cmmercer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-25-2014, 06:32 AM
  4. [SOLVED] Vba code makes workboos slow. Any alternate code ??
    By satputenandkumar0 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-23-2014, 04:30 AM
  5. Why is this code slow?
    By foxguy in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-16-2010, 02:05 PM
  6. [SOLVED] Better Way To Do This SLOW code
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2006, 04:30 AM
  7. Slow Code
    By Shawn in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-23-2005, 04: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