Forum Discussion

DanielAtGSU's avatar
DanielAtGSU
Copper Contributor
Apr 15, 2022
Solved

Help: Highlighting Only the First Duplicate

I have two columns of data. I'm comfortable with conditional logic and I've made the data consistent between the two columns so that highlighting duplicates is error-proof.

 

Here's where it gets bumpy: In Column B, I only need to highlight the FIRST instance of a duplicate value that exists in Column A. If that doesn't make sense, I don't know of any other way to explain it.

 

Current Situation:

Current Situation

 

Desired Outcome:

Desired Outcome

 

 

ALTERNATE SOLUTION:

 

I'll also accept the inverse scenario as it could be easy to filter: In Column B, highlight any duplicate (beyond the first) of a value that exists in Column A.

  • DanielAtGSU 

    Select B1:B9 (or to the end of the data). B1 should be the active cell in the selection.

    Create a rule of type 'Use a formula to determine which cells to format' with formula

     

    =AND(ISNUMBER(MATCH(B1,A:A,0)),COUNTIF(B$1:B1,B1)=1)

     

20 Replies

  • DanielAtGSU 

    Just for the sake of it, a slightly different approach to identifying the first occurrence of each string.

    Because CF is a pile of antiquated functionality, one is forced to use relative referencing rather than array formulas.  First I provided a name for the current cell, which I show in R1C1 notation whereas A1 notation would give me any one of 17 billion ways of writing the same thing.

    currentCell = Sheet1!RC;
    
    firstInstance? 
    = ISREF(
         currentCell  XLOOKUP(currentCell, sessions, sessions)
      );

    The Boolean Named Formula firstInstance? looks up the current cell value in the list of sessions and returns a reference to the first occurrence.  If that reference and the current cell are one and the same, the argument of ISREF( ) will be the reference, otherwise a NULL error, giving TRUE/FALSE.  The formatting depends upon firstInstance?

     

  • DanielAtGSU 

    Select B1:B9 (or to the end of the data). B1 should be the active cell in the selection.

    Create a rule of type 'Use a formula to determine which cells to format' with formula

     

    =AND(ISNUMBER(MATCH(B1,A:A,0)),COUNTIF(B$1:B1,B1)=1)

     

    • ginag2470's avatar
      ginag2470
      Copper Contributor

      HansVogelaar 

       

      I have tried all of the formulas but none of them are working. I am working with dates, does that make a difference?

       

      • SergeiBaklan's avatar
        SergeiBaklan
        Diamond Contributor

        ginag2470 

        Bu sure you correctly use first cell of the range to apply in formula, in general it shall work

        Here first of duplicated values is highlighted and any value without duplicates.

    • DanielAtGSU's avatar
      DanielAtGSU
      Copper Contributor

      HansVogelaar  - I tested it with the sample text, and it works. But I'm having difficulty applying it to my project. The columns contain email addresses along with some appended (concatenated) text to serve as a unique identifier.

       

      Originally, I had an asterisk between the date (first 8 characters) and the email. I thought it might be interfering, so I replaced it with "ZZZ" and can remove it later. I then thought the "@" was the problem, so I replaced that with "XXX" and can remove that later. Regardless, the formula you suggested should work here, right? It doesn't, and I can't figure out why not. 

       

      In writing this, I also replace the period in ".com" just to see. Nothing. Still doesn't work. It's just text, so why isn't it being recognized as a match? 

       

      • HansVogelaar's avatar
        HansVogelaar
        MVP

        DanielAtGSU 

        Could you attach a sample workbook, or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?

Resources