Remove duplicate phone numbers on same row

  • I have a table with a large number of customer ID's in column A and associated customer data in columns to the right.
    10 to 15 columns will contain phone numbers. The problem is the same phone number will appear in more than one column.
    I would like to delete the duplicates keeping just the first occurrence of the number. (closest to column A).
    All of the columns have labels and columns containing phone numbers have "Phone" somewhere in the label. (the column order changes sometimes so I can't specify by column number)


    Any help greatly appreciated!! (sample data attached)


    forum.ozgrid.com/index.php?attachment/64842/

  • Re: Remove duplicate phone numbers on same row


    Hi Jaffey,


    Your solution might depend on how frequently you want to do this. If it's a one-off, you can create a new set of columns to the right of your existing data and use this formula for the first phone number:


    =IF(COUNTIF($D$3:D3,D3)=1,D3,"")


    Fill this to the right for 7 columns, and then down as many rows as necessary. Then copy and paste special / values over the original.

    [COLOR="Purple"]Regards,[/COLOR]
    [COLOR="Purple"]Batman.[/COLOR]

  • Re: Remove duplicate phone numbers on same row


    Thank you for responding! Unfortunately I have to do this every day and there 10's of 1000's of rows to deal with in multiple list, plus there are many other columns of various customer data inserted between the phone number columns. Nice formula though, works very nicely :)

  • Re: Remove duplicate phone numbers on same row


    See if this works

  • Re: Remove duplicate phone numbers on same row


    Thank you so much Jindon. Unfortunately I am getting a type mismatch error on the following line when I use it on real data:


    txt = Join(Application.Index(a, i, 0), Chr(2))


    The data is in Excel table format. Would that make a difference? I tried converting it to a range but that didn't help.


    When I try it with the test data I provided it's working but I noticed that with one of the phone numbers it truncated the area code of the firs occurrence of the number.


    i.e. 905747899 in Cell H4 becomes 7477899 after I run it.

  • Re: Remove duplicate phone numbers on same row


    When I run it on the raw csv files it runs fine. I have another macro that converts the csv files to tables upon opening but when I turn that off it elimiates the type mismatch error. The only issue remaining is that it seems to be corrupting some of the phone numbers. Are you seeing that with the test data provided? When I run it on the test data the phone number in H4 gets shortened.

  • Re: Remove duplicate phone numbers on same row


    Yep, it should be like this

  • Re: Remove duplicate phone numbers on same row


    Now you are asking totally different question...


    See if this works.

  • Re: Remove duplicate phone numbers on same row


    Working perfectly!! Thank you so much!! (please note I had to add "Dim a, x, i,ii As Long, txt As String" at the beginning)

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!