+ Reply to Thread
Results 1 to 11 of 11

Finding Duplicate Cell (values) within same row

  1. #1
    Registered User
    Join Date
    06-23-2019
    Location
    Houston, TX
    MS-Off Ver
    Micrsoft Office Professional Plus 2016
    Posts
    2

    Finding Duplicate Cell (values) within same row

    I have searched for this answer but I haven't been able to find exactly what I'm looking for. I am trying to find and remove duplicates but only within the same row. Example,


    8729 1245 9321 8729

    4236 1829 8729 7845

    3435 1171 3435 1171


    There are two similar values of "8729" in Row 1, and one value of "8729" in row 2......I want to remove one of those values in Row 1 without removing the value in Row 2. Basically, remove a value if it's already present in a single row. While at the same time, that value can be present in any/every other row.

    I hope that explanation was clear....thank you in advance.
    Last edited by afarmer83; 06-24-2019 at 08:51 AM. Reason: A member was able to answer the question

  2. #2
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Finding Duplicate Cell (values) within same row

    Perhaps something like
    Please Login or Register  to view this content.
    Select the range of cells to search for duplicates, then run the code. Please test on a copy of your file, not the original,this is to prevent data loss if it doesn't work as expected.

  3. #3
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Finding Duplicate Cell (values) within same row

    Here is a formula based attempt in case you can't use the VBA solution for some reason.
    Using your example, select F1:I1 then enter the following in the formula bar:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    This is an array formula and must be committed with CTRL-SHIFT-ENTER.
    With F1:I1 still selected copy then paste to F2:I5. You should now have the following:

    noDups.png

    There's a couple of possible disadvantages relative to the VBA approach. Firstly the data is not adjusted "in place" and secondly there will be "gaps" in the row where duplicate values have been removed.
    Geoff

    Did I help significantly? If you wish, click on * Add Reputation to say thanks.
    If your problem has been resolved please select ?Solved? from the Thread Tools menu

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Finding Duplicate Cell (values) within same row

    Quote Originally Posted by GeoffW283 View Post
    There's a couple of possible disadvantages relative to the VBA approach. Firstly the data is not adjusted "in place" and secondly there will be "gaps" in the row where duplicate values have been removed.
    Not adjusted in place? I would say that it is adjusted in place, where as a formula replicates it in another place.
    Secondly, the gaps produced by the vba are no different to those in the results of your formula.

  5. #5
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Finding Duplicate Cell (values) within same row

    @jason.b75

    Not adjusted in place? I would say that it is adjusted in place, where as a formula replicates it in another place.
    Maybe I could have been clearer, but we're in violent agreement. I said: "There's a couple of possible disadvantages [of my formula based approach] relative to the VBA approach. Firstly the data is not adjusted "in place" [by my formula based approach] " . . .

    the gaps produced by the vba are no different to those in the results of your formula.
    That happens to be true for the OP's three examples as the duplicates occur in the last column. For my additional example in the 4th row:
    | 2 | 2 | 2 | 1 |
    You generate:
    | 2 | 1 | | |
    I generate
    | 2 | | | 1 |

    In summary, I was trying to say that your VBA solution is superior to my formula based solution I provided my attempt only in case the OP can't use a VBA approach.
    Last edited by GeoffW283; 06-23-2019 at 11:45 PM.

  6. #6
    Registered User
    Join Date
    06-14-2019
    Location
    Charlotte, NC, USA
    MS-Off Ver
    Office 365
    Posts
    20

    Re: Finding Duplicate Cell (values) within same row

    I understand the frequency part, but what is the transpose doing in this formula? This looks great, I'm just trying to wrap my head around what's going on.

  7. #7
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Finding Duplicate Cell (values) within same row

    frequency() returns a vertical array of values. transpose() converts that vertical array into a horizontal array as the requirement here is to put the result in a single row.

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: Finding Duplicate Cell (values) within same row

    Edited Added data.

    Another way. Array entered in F1 (Ctrl + Shift + Enter) filled across and down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    8729
    1245
    9321
    8729
    8729
    1245
    9321
    2
    4236
    1829
    8729
    7845
    4236
    1829
    8729
    7845
    3
    3435
    1171
    3435
    1171
    3435
    1171
    4
    2
    2
    2
    1
    2
    1
    5
    1
    2
    2
    3
    2
    1
    3
    Last edited by FlameRetired; 06-24-2019 at 12:47 AM.
    Dave

  9. #9
    Registered User
    Join Date
    06-14-2019
    Location
    Charlotte, NC, USA
    MS-Off Ver
    Office 365
    Posts
    20

    Re: Finding Duplicate Cell (values) within same row

    Got it, that makes sense. One thing that is still confusing is... why does it return a frequency of 0 for the duplicate item? Does it basically ignore another 'bin' of the same name?

  10. #10
    Registered User
    Join Date
    06-23-2019
    Location
    Houston, TX
    MS-Off Ver
    Micrsoft Office Professional Plus 2016
    Posts
    2

    Re: Finding Duplicate Cell (values) within same row

    Geoff,

    This is 100% the solution I was looking for. I was racking my brain for several days trying to find the answer and this worked on my first attempt....thank you so much!!

  11. #11
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Finding Duplicate Cell (values) within same row

    @izzy-analytics:
    "why does it return a frequency of 0 for the duplicate item?"
    I suppose there is a degree of logic in that elements will be assigned to the first eligible bin that is encountered, but this and many other quirks of various functions are not documented by Microsoft and so it's either trial and error or learning from others on sites like this (I know I'm going to study FlameRetired's mode.mult solution!). Hope this helps. Thanks for the rep!

    @afarmer83: Thanks for the feedback - glad it works for you!
    Last edited by GeoffW283; 06-24-2019 at 12:21 PM.

+ 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. Finding duplicate values in two columns
    By forestavekids in forum Excel General
    Replies: 5
    Last Post: 05-30-2017, 06:59 AM
  2. [SOLVED] Finding Row numbers of all duplicate values
    By Dj Duck in forum Excel General
    Replies: 6
    Last Post: 10-03-2015, 07:18 AM
  3. [SOLVED] Finding duplicate values in rows
    By fitkhan in forum Excel General
    Replies: 2
    Last Post: 03-24-2014, 04:53 AM
  4. Finding duplicate values
    By sagar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-23-2014, 06:12 PM
  5. Finding duplicate values
    By sagar in forum Excel General
    Replies: 2
    Last Post: 02-23-2014, 03:39 AM
  6. Finding Duplicate Values in a Col,
    By Rajkumar in forum Excel General
    Replies: 2
    Last Post: 03-05-2008, 09:33 AM
  7. Finding duplicate values b/w two columes
    By nikki115 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2006, 12:10 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