+ Reply to Thread
Results 1 to 5 of 5

Use of filter vs. looping through cells

  1. #1
    Registered User
    Join Date
    05-19-2015
    Location
    Tokyo
    MS-Off Ver
    10
    Posts
    17

    Use of filter vs. looping through cells

    I have a table with 2 columns, A contains either "Yes" or "No" while B contains other data.

    I have a macro that takes all values where A = "Yes" and copies the rows to a different one.

    Currently, I recorded the macro setting a filter by column a = "Yes" before copying the results.
    Is it looping through column A, row by row, a more efficient option? I am wondering if this will require more resources from the pc (there can be 10 to 20 thousandth rows).

    Thanks.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Use of filter vs. looping through cells

    I would think that if you have a macro that 1st sets the filter to Yes, then copies what remains, to another location - and you have 10's of thousands of rows, that would be far quicker than having code loop through each entry and then copy 1 row at a time.

    Doing the filter/copy/paste manually would probably take seconds - the macro for that would hardly take much longer
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Use of filter vs. looping through cells

    I would think that if you have a macro that 1st sets the filter to Yes, then copies what remains, to another location - and you have 10's of thousands of rows, that would be far quicker than having code loop through each entry and then copy 1 row at a time.

    Doing the filter/copy/paste manually would probably take seconds - the macro for that would hardly take much longer

  4. #4
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: Use of filter vs. looping through cells

    I strongly suggest you test both codes, and time the results. It's a lot of fun to compare the speed of two or more algorithms, both of which give the same end result, but do the task in different ways. You end up learning a LOT in the process.

    25 years after learning about all of the many ways there are to SORT a list of items (bubble sort, heap sort, insertion sort, quick sort, merge sort, shell sort, library sort etc., etc.) I'm STILL fascinated by that subject!

  5. #5
    Registered User
    Join Date
    05-19-2015
    Location
    Tokyo
    MS-Off Ver
    10
    Posts
    17

    Re: Use of filter vs. looping through cells

    Indeed, I will try both options and find the one that works best.

    Thank you!

+ 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. Macro to filter a pivot whilst looping through filter criteria in a variable list.
    By Alistairm88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2015, 04:25 AM
  2. looping through pivot table filter
    By ShaliniGomes in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-25-2014, 12:02 AM
  3. Looping through a Range,Filter and copy visible cells
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-31-2011, 02:14 PM
  4. Looping with an Advanced FIlter
    By Jay3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-09-2009, 12:35 PM
  5. Looping filter criteria
    By VBA Noob in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-13-2006, 01:00 PM

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