+ Reply to Thread
Results 1 to 9 of 9

remove duplicate value within a row but keep first found value and remove the rest

  1. #1
    Registered User
    Join Date
    10-10-2012
    Location
    balikpapan
    MS-Off Ver
    Excel 2016
    Posts
    15

    remove duplicate value within a row but keep first found value and remove the rest

    Hi MVPs

    i currently working on a list which contains several data horizontally, it contain some duplicate value within a row. i want to remove all duplicate but keep first found value and not delete entire row. since it's over 9000 rows, it would be painfull to do it manually

    please your kind help and attached file for you to have clarity about what my problem is

    thank you very much for your help

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: remove duplicate value within a row but keep first found value and remove the rest

    Are you still using Excel 2010?

    With 365 you can use:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-10-2012
    Location
    balikpapan
    MS-Off Ver
    Excel 2016
    Posts
    15

    Re: remove duplicate value within a row but keep first found value and remove the rest

    i forgot to change excel version in my profile, no currently i'm using 2016 version

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Re: remove duplicate value within a row but keep first found value and remove the rest

    For Excel 2016:

    =IFERROR(INDEX(2:2,AGGREGATE(15,6,COLUMN($B2:$Q2)/(($B2:$Q2<>"")*(COUNTIF($A7:A7,$B2:$Q2)=0)),1)),"")

    copied across and down.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: remove duplicate value within a row but keep first found value and remove the rest

    vba
    try
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-10-2012
    Location
    balikpapan
    MS-Off Ver
    Excel 2016
    Posts
    15

    Re: remove duplicate value within a row but keep first found value and remove the rest

    Glenn Kennedy & jindon

    please accept the star to both of you, both solution is exactly what i need. this thread is SOLVED

    thank you so much

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: remove duplicate value within a row but keep first found value and remove the rest

    Another option
    Assuming your source sheet is Sheet1, the result will be in Sheet2.

    PHP Code: 
    Option Explicit
    Sub dup
    ()
    Dim lr&, i&, j&, k&, rngdic As Objectspsres(), As Boolean
    With Sheets
    ("Sheet1")
        
    lr = .Cells(Rows.Count"A").End(xlUp).Row ' last used row of col A
        rng = .Range("A2:M" & lr).Value ' 
    expand range into actual range
        ReDim res
    (1 To UBound(rng), 1 To UBound(rng2))
    End With
    For 1 To UBound(rng)
        
    Set dic CreateObject("Scripting.Dictionary")
        
    0
        
    For 1 To UBound(rng2)
            If 
    Not IsEmpty(rng(ij)) Then
                c 
    Falsesp Split(rng(ij), ",")
                For 
    Each s In sp
                    
    If Not dic.exists(sThen
                        dic
    .Add s""
                        
    True
                    End 
    If
                
    Next
                
    If c Then k 1res(ik) = rng(ij)
            
    End If
        
    Next
    Next
    Sheets
    ("sheet2").Activate
    Range
    ("A2:XX100000").ClearContents
    Range
    ("A2").Resize(UBound(res), UBound(res2)).Value res
    End Sub 
    Quang PT

  8. #8
    Registered User
    Join Date
    10-10-2012
    Location
    balikpapan
    MS-Off Ver
    Excel 2016
    Posts
    15

    Re: remove duplicate value within a row but keep first found value and remove the rest

    Quote Originally Posted by TMS View Post
    Are you still using Excel 2010?

    With 365 you can use:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    tested to my personal laptop which using 365 and worked as well, even currently i'm working at company that still using 2016, please accept the star for you

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: remove duplicate value within a row but keep first found value and remove the rest

    You're welcome. Thanks for the rep.

+ 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. Replies: 3
    Last Post: 04-26-2017, 08:01 PM
  2. Replies: 1
    Last Post: 11-14-2014, 07:45 PM
  3. Replies: 1
    Last Post: 12-11-2013, 09:09 PM
  4. excel macro to remove specific columns and rows + remove duplicate
    By garrywelson in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-17-2013, 12:03 PM
  5. Keep only duplicate records and remove the rest
    By Helal in forum Excel General
    Replies: 1
    Last Post: 12-13-2012, 12:02 AM
  6. VB Script req plz - 2 .XLS files; remove duplicate account # found in second .XLS file.
    By DoraExplorExcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-19-2012, 12:21 AM
  7. 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

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