+ Reply to Thread
Results 1 to 8 of 8

VBA - Advanced Filter / Find Row Items to Remove Based on Multiple Criteria

  1. #1
    Registered User
    Join Date
    06-19-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    24

    VBA - Advanced Filter / Find Row Items to Remove Based on Multiple Criteria

    I'm working with many rows of data (500,000+) and many columns. To simplify my question, I'm going to provide a simple example using made up numbers and only the columns I'm concerned with.

    BillT Doc. Item Qty
    F1 123 10 12.00
    F2 123 20 5.00
    S1 123 10 5.00
    RE 321 20 2.00
    F2 321 10 8.00
    F2 321 20 1.00
    RE 321 20 3.00
    RE 999 80 8.00
    F2 777 100 1.00
    RE 777 100 1.00

    I am trying to remove the docs that have two Bill types that cancel each other out, where the qtys match and highlight the rows where the qtys don't match.
    The macro needs to have the positive and negative bill types programatically entered, where for example F1 and F2 are positive and S1 and RE are negative. Keep in mind the data may not necessarily be in order as it is above.

    So for example with data above, the rows for doc 777 would be removed completely because the item numbers are the same, the qty is the same, and the bill types oppose each other. Doc 123 and Item 10 lines should be highlighted since their bill types are opposed bu their qtys don't match.

    I hope this makes sense. I tired to achieve this using multiple loops and arrays, but ran out of memory when working with the entire set of data. I'm assuming their must be a better way to do this, I'm hoping some of the intelligent individuals here will be able to point in the right direction.

    Thanks in advance for the assistance

  2. #2
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: VBA - Advanced Filter / Find Row Items to Remove Based on Multiple Criteria

    What is the rule to identify positive and negative bill types?
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

  3. #3
    Registered User
    Join Date
    06-19-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: VBA - Advanced Filter / Find Row Items to Remove Based on Multiple Criteria

    F1 and F2 are positive. Everything else is negative.

  4. #4
    Registered User
    Join Date
    06-19-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: VBA - Advanced Filter / Find Row Items to Remove Based on Multiple Criteria

    Anybody? Any help or guidance would be much appreciated. If it helps at all here is the code I'm currently trying to make work, but I get an Out of Memory warning when working with all the data.

    Please Login or Register  to view this content.
    I'm hoping there is an easier way that doesn't require so many loops and arrays.

  5. #5
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: VBA - Advanced Filter / Find Row Items to Remove Based on Multiple Criteria

    Don't rush the elderly
    Indeed the huge amount of rows and possible itterations requires a non-sequential approach.
    Well on my way figuring that out.

  6. #6
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: VBA - Advanced Filter / Find Row Items to Remove Based on Multiple Criteria

    Try this code.
    It's reducing the number of comparisons by using autofilter.
    Don't mind the select case part; that's where your business logic comes. Nor the hard coded bill types. That's the easiest part, which you probably can do yourself.
    What I'm interested in is how long it takes to run this procedure on 500000+ rows.
    The macro is not deleting rows, just marking them red.
    Please Login or Register  to view this content.
    Last edited by Tsjallie; 07-01-2014 at 03:28 PM.

  7. #7
    Registered User
    Join Date
    06-19-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: VBA - Advanced Filter / Find Row Items to Remove Based on Multiple Criteria

    Thanks for your reply, Tsjallie.

    I started running the code yesterday at 4:04 PM. It is currently 8:52 AM and the code has gotten through about 105,000 lines.

    It appears to be working correctly however in the small test I did before running the entire thing. I will keep you posted on the end result.

    I really appreciate the help.

  8. #8
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: VBA - Advanced Filter / Find Row Items to Remove Based on Multiple Criteria

    That's almost 5 hrs for getting through 100K rows.
    I think you should forget this approach.
    Keep in mind the data may not necessarily be in order as it is above.
    Would it be a problem if the data gets sorted before starting the procedure?

  9. #9
    Registered User
    Join Date
    06-19-2012
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2007
    Posts
    24

    Re: VBA - Advanced Filter / Find Row Items to Remove Based on Multiple Criteria

    No that wouldn't be a problem at all.

    Subsequent running of this code will be with much smaller data sets, so the approach could still work. It's just this first time that the dataset is so large.

+ 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. Advanced filter using multiple criteria
    By logan131131 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-16-2012, 11:36 AM
  2. [SOLVED] Advanced Filter: Problem with Multiple AND/OR Criteria
    By excelnewbie80 in forum Excel General
    Replies: 2
    Last Post: 06-18-2012, 09:00 AM
  3. Advanced Filter with multiple criteria
    By inspiresit in forum Excel General
    Replies: 6
    Last Post: 08-12-2010, 11:21 AM
  4. advanced filter through vba with multiple criteria
    By edoylederry in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-08-2010, 07:23 AM
  5. Advanced filter on multiple criteria
    By agalloch in forum Excel General
    Replies: 2
    Last Post: 08-19-2009, 09:48 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