+ Reply to Thread
Results 1 to 6 of 6

Improve code performance to Optimize Loops

  1. #1
    Registered User
    Join Date
    05-27-2011
    Location
    Virginia
    MS-Off Ver
    Excel 365
    Posts
    86

    Improve code performance to Optimize Loops

    Hi,

    Is there a more efficient way to optimize the code below to improve its performance because on a large data set with over 20,00o records it is very slow?
    Thanks in advance for any assistance that you can provide.

    Please Login or Register  to view this content.
    i

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Improve code performance to Optimize Loops

    It would be helpful to see a sample workbook (see yellow banner at the top of the page) but I don't understand why you seem to be testing the same conditions repeatedly , namely:

    Please Login or Register  to view this content.
    Rory

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Improve code performance to Optimize Loops

    Untested, but this might do what you want:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    05-27-2011
    Location
    Virginia
    MS-Off Ver
    Excel 365
    Posts
    86

    Re: Improve code performance to Optimize Loops

    Thanks a million rorya for your expertise. This works quit well. It cuts my time down to a fraction of my previous time.

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

    Re: Improve code performance to Optimize Loops

    Glad we could help.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Improve code performance to Optimize Loops

    Hi,

    Since you're essentially testing three conditions, columns 10 & 11, 11 & 12 and 12 & 13 , and writing N/A to either columns 11:12, 12:18 or just 13, another approach would be to use a helper column and use standard Excel IF...Functions to flag it and identify which of the three is relevant.

    Then all you need do is use an Autofilter three times and use the .SpecialCells(xlCellTypeVisible) syntax to update the relevant columns with the N/A.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ 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. Improve performance
    By twister889 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-17-2020, 03:08 PM
  2. Please assit to Optimize the performance
    By naresh73 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-22-2018, 07:39 PM
  3. Replies: 2
    Last Post: 02-26-2016, 03:15 AM
  4. How to improve performance of my code?, now is too slow!!
    By Laurelb in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-25-2015, 03:15 PM
  5. VBA For loop, optimize speed and performance
    By britzer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-04-2014, 08:56 AM
  6. improve performance
    By david90 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2013, 01:12 AM
  7. [SOLVED] optimize macro - cutting down loops and autofill
    By gwsampso in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-04-2012, 12:56 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