+ Reply to Thread
Results 1 to 2 of 2

If two duplicate values are found in column A, then remove the entire row of one

  1. #1
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    298

    If two duplicate values are found in column A, then remove the entire row of one

    Remove duplicates didn't seem to work so well.

    I need something that will, for every duplicate value in column A, remove one of the rows associated with it. Does not matter which one.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: If two duplicate values are found in column A, then remove the entire row of one

    Try running this Macro.

    Sub Macro2()

    LR = Selection.SpecialCells(xlCellTypeLastCell).Row
    LC = Selection.SpecialCells(xlCellTypeLastCell).Column + 1

    ActiveSheet.Sort.SortFields.Add Key:=Range("A1:A" & LR) _
    , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet1").Sort
    .SetRange Range("A1:A" & LR)
    .Header = xlGuess
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
    End With

    Range(Cells(1, LC), Cells(LR, LC)).FormulaR1C1 = "=IF(RC[" & 1 - LC & "]=R[1]C[" & 1 - LC & "],1,"""")"
    Range(Cells(1, LC), Cells(LR, LC)).Value = Range(Cells(1, LC), Cells(LR, LC)).Value
    Range(Cells(1, LC), Cells(LR, LC)).SpecialCells(xlCellTypeConstants, 1).Select
    Selection.EntireRow.Delete
    Columns(LR & ":" & LR).delete
    Range("A1").select
    End Sub

+ 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. [SOLVED] Delete entire row if one column contains duplicate values
    By dawsonsoo in forum Excel General
    Replies: 4
    Last Post: 08-26-2014, 09:55 AM
  2. delete the entire row if duplicate found in column
    By gujugolf in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-15-2013, 04:07 PM
  3. Remove rows with duplicate values in one column based on value of another column
    By jolleyje in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-15-2013, 06:20 AM
  4. Replies: 4
    Last Post: 09-18-2012, 09:06 AM
  5. loop through data twice & remove row if duplicate values are found
    By smokebreak in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-22-2010, 02:29 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