+ Reply to Thread
Results 1 to 8 of 8

Deleting duplicates in a range of rows

  1. #1
    Registered User
    Join Date
    01-04-2011
    Location
    Netheerlands
    MS-Off Ver
    Excel 2003
    Posts
    12

    Deleting duplicates in a range of rows

    Dear people,

    I have the following problem within Excel. I have a dataset which contains duplicate values within a column(lets say A).
    I need to delete these duplicates in column A for a range of rows, where the range of the rows is based on column B.
    So for a given value in column B, lets say 5 which is 6 rows long all beneath each other, I need to delete the duplicates in column A.

    A B
    1 2234
    4 2234
    5 2234
    4 2234
    2 2234
    3 2234
    5 2234
    5 2657
    8 2657
    9 2657
    10 2657
    8 2657
    9 2657
    2 2657

    So above the red numbers need to be removed, automatically, since we have about 8000 rows in our dataset.
    Can someone give me a tip on how to approach this?

    Greetings Michiel

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Deleting duplicates in a range of rows

    Hi Michiel.

    You just want to delete the duplicate value in col A. col B won't be affected? Just confused. You don't want the entire row to be deleted. Do you?
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Registered User
    Join Date
    01-04-2011
    Location
    Netheerlands
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Deleting duplicates in a range of rows

    Actually I do want the whole row to be deleted. Sorry for the confusion.

    I thought of the following idea: first take the column B and remove all duplicates from that column only and copy to column C. This way you will have all the unique values of column B. Then, write a routine that takes every value from column C one by one, searches for the range of rows which contain a value from column C in column B and searches for those range of rows in column A for duplicates to eventually delete them.
    Last edited by Mkkl; 03-22-2013 at 09:15 AM. Reason: Forgot something

  4. #4
    Registered User
    Join Date
    01-04-2011
    Location
    Netheerlands
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Deleting duplicates in a range of rows

    Is there someone who can think of a way to implement this idea in Excel?

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Deleting duplicates in a range of rows

    One other way could be this.

    In a Column(let's say E) in E1, put this.

    =IF(A1="","",A1)

    In E2 and copy down, this one.

    =IFERROR(INDEX(A$1:A$10,MATCH(1,INDEX((COUNTIF(E$1:E1,A$1:A$10&"")=0)*(A$1:A$10<>""),0),0)),"")

    In F1 and copy down use this

    =IFERROR(INDEX($B$1:$B$10,MATCH(E1,$A$1:$A$10,0)),"")

    Now you have your new data.

    If you don't want to have all these column, you can do this.

    Highlight column E & F. >>>COPY

    Choose another empty column(LET'S SAY H:I)>>Paste Special>>Only Values>>OK.

    Delete columns A&B&E&F.

    Highlight H:I >>Cut. Go to A1 Paste >>ok.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Deleting duplicates in a range of rows

    The data in column A is single digit but the data in column B is 4 digit. How do you say they are duplicate?

    Also, i didnt understand this statement from post 1 - So for a given value in column B, lets say 5 which is 6 rows long all beneath each other, I need to delete the duplicates in column A.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  7. #7
    Valued Forum Contributor Lemice's Avatar
    Join Date
    04-13-2013
    Location
    Somewhere.
    MS-Off Ver
    Excel 2016
    Posts
    696

    Re: Deleting duplicates in a range of rows

    Hello,

    I suggest making a helper column, something in Column C like this
    Please Login or Register  to view this content.
    Like in this sample file
    Check duplicate.xls
    Then, you can just find the row with 1 and delete it all!

    Hope this help.
    (copy pasta from Ford)
    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

    Regards,
    Lem

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Deleting duplicates in a range of rows

    c1 =A1&"-"&B1
    d1 =COUNTIF($C$1:C1,C1)=1
    fill down
    filter on false
    delete visible rows
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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