+ Reply to Thread
Results 1 to 5 of 5

Filter duplicate rows based on cell value

  1. #1
    Registered User
    Join Date
    12-16-2014
    Location
    Charlotte NC
    MS-Off Ver
    Mac Excel 2011
    Posts
    13

    Filter duplicate rows based on cell value

    I'm combing two sheets into one and need to perform filtering tasks.

    1. Search for duplicates (I'm able to perform this)

    2. Compare duplicate rows:

    3. If there is a duplicate, compare the cell value in column C and determine which date (mm/dd/yy) is older.

    4. Delete the row that has the older date. (Shift rows (up/down) to eliminate the empty row.)

    OR

    4. Add a "status" column to each duplicate row. (i.e. "new", "old")

    The outcome using the attached example should result in the following:
    1. Find 1 duplicate.
    2. Compare rows 2 and 5.
    3. Compare dates in column C (2/20/17 and 2/22/17).
    4. Determine that 2/20/17 is older and delete Row 2.
    OR
    4. Create a column D that shows a status outcome of each row.

    example.png

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Filter duplicate rows based on cell value

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    12-16-2014
    Location
    Charlotte NC
    MS-Off Ver
    Mac Excel 2011
    Posts
    13

    Re: Filter duplicate rows based on cell value

    I've attached a spreadsheet with 3 tabs. A before, and 2 after examples. Hope this explains it well enough.
    Attached Files Attached Files

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Filter duplicate rows based on cell value

    I've done some "slight of hand" on his one.

    First, I changed the data range to an Excel table. Excel tables have a lot of benefits: they know how big they are so you don't have to adjust formulas when you change the number of rows. They copy formulas down automatically. They used column headers instead of addresses in the formulas.

    I added a helper column called Composite - since what makes a record unique is the combination of Product and Packaging, I concatenated them together into a "Composite Key" to see if the record is unique.

    Then I found the maximum date for the composite key: =MAX(IF([Composite]=[@Composite],IF(NOT(ISBLANK([Package Date])),[Package Date],FALSE))) - this is entered as an array formula. The explanation of array formulas and this specific example is explained here: http://www.utteraccess.com/wiki/Array_Formulas. Essentially, this formula looks at the composite and considers only dates associated with that composite.

    The Where Found Column has another array formula: =MATCH([@[Max Date]],IF([Composite]=[@Composite],[Max Date],FALSE),0) - This finds where the max date occurs for that composite key.

    The Use Column has the formula: =MATCH([@[Where Found]],F:F,0)=ROW() - this formula is true for the first occurrence of the item and false otherwise. For example the value 1 appears twice in column F. The one in row 2 "counts;" the one in row 5 doesn't. I use this as a filter in the pivot table.

    Then I make a pivot table based on this. If you right click on a field and go to field settings, you can select none for subtotals, then go to the layout & print tab and select show items in tabular form. I did this for row labels, product, packaging and date. That's why they wind up on the same line in the pivot table.

    What is good about this is that you can clear out the contents of the table by selecting rows 2 to 6 (the data rows, not the headers), right clicking on them and selecting Delete -> Table Rows from the menu. Then you can copy and paste your real data into Cell A2. The table will "remember" the formulas contained in Columns D:G and copy them down automatically. Then right click in the pivot table and select refresh from the menu.

    Here is an article that will get you started on Excel Tables: http://www.utteraccess.com/wiki/Tables_in_Excel - after a while you will wonder how you ever managed to get along without them.

    You can hide the helper columns if you wish.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-16-2014
    Location
    Charlotte NC
    MS-Off Ver
    Mac Excel 2011
    Posts
    13

    Re: Filter duplicate rows based on cell value

    This is great, thank you! Very thorough. I'll read through material and spreadsheet to digest. I simplified the sheet and left out a couple of columns so that I could best explain the specific question/problem. I should be able to make a couple adjustments based on your detailed explanation though.
    Cheers

+ 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 duplicate rows based on cell value
    By KBEZ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-24-2016, 11:58 AM
  2. duplicate rows based on cell value
    By epi in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 08-05-2014, 11:33 AM
  3. Duplicate rows based on the numeric value of a cell
    By ATMEDIA in forum Excel General
    Replies: 2
    Last Post: 07-10-2014, 12:35 PM
  4. Duplicate Rows based on cell value
    By Reverend in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-20-2014, 11:06 AM
  5. how to filter the rows based on a column which contains duplicate values...
    By Rajesh Ushakoyyala in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-04-2013, 10:49 AM
  6. [SOLVED] Delete rows based on duplicate cell, but leaving first and last duplicate.
    By LadyNicole in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-28-2013, 05:07 AM
  7. Merge rows based on duplicate cell
    By skacutter in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-15-2010, 09:47 AM

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