+ Reply to Thread
Results 1 to 4 of 4

Compare 2 rows for different criteria

  1. #1
    Registered User
    Join Date
    12-12-2013
    Location
    Charlotte
    MS-Off Ver
    Excel 2007
    Posts
    2

    Compare 2 rows for different criteria

    Hi all,

    I've come to a problem that I can't figure out and humble ask for some guidance. I'm not sure how to best describe what the report is but I can describe what I need it to do. I want the macro to:

    compare E2 to E1
    If E2/E1 match, then compare D2 to D1
    If D2/D1 match then go to the next line and compare E3 to E2
    If D2/D1 don't match, delete row 2.
    If E2/E1 don't match, then go to the next line and compare E3 to E2

    I want this to run on every line all the way through to the end of the report. I feel like this should be easy to program but I'm new to vba and most of what I've learned has been by doing it in a macro then reverse engineering it. Thanks so much for the help!

    Example.xlsx
    Last edited by jcboyle82; 12-12-2013 at 03:16 PM. Reason: attached an example workbook

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,639

    Re: Compare 2 rows for different criteria

    It would be better if you upload a sample workbook with some sample data in it and highlight the rows which you want to delete as per your criteria with an explanation in the sheet itself. To do so your sample workbook may contain two worksheets "Before" and "After". In the Before sheet just input some sample data and in After sheet display the desired output.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    03-31-2011
    Location
    Manchester
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Compare 2 rows for different criteria

    If the invoice count is always 1 or 2 try this

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-12-2013
    Location
    Charlotte
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Compare 2 rows for different criteria

    Sometimes the count goes up to 4 but it is rare. This highlights in yellow the ones I want to delete but highlights in green the ones I don't. Unfortunately, I found that it highlighted in yellow an incorrect one. Here is what it did:


    Jones, Bob ABC123456789 03/22/2013 1 481333-026 $0.00 MO 0 63,126.45
    Jones, Bob EFG123456789 05/02/2013 2 481333-026 $0.00 MO 0 65,189.32

    It highlighted the first row green and second row yellow. I'm not sure why.


    ***sorry for the formatting, Im not sure how to spread it out so it's clearer to read***

+ 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 Find Rows With Duplicates, Compare Cells, And Delete Rows. - Excel
    By Kwame001 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2013, 10:41 AM
  2. Replies: 9
    Last Post: 08-07-2013, 02:21 PM
  3. Replies: 13
    Last Post: 08-23-2011, 11:00 AM
  4. Compare rows, cut matches to sheet, delete original rows
    By somesoldiers in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2010, 11:42 AM
  5. Replies: 5
    Last Post: 09-22-2009, 06:11 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