简体   繁体   中英

Excel - how to find duplicates cells ONLY for cells containing specific text

I've been fiddling with conditional formatting rules in excel for a while and I can't figure this out.

I want to automatically highlight any duplicate cells -- but i only want certain cells to be considered.

So I need excel to only search cells containing this partial text string "<<<", and then tell me which of those is a duplicate by hilighting the cells.

I need all cells which do not contain "<<<" to be ignored.

thx

Maybe this site will point you in the right direction. I don't think it will fully answer your question but it will help (if you are open to a VBA solution).

EDIT

I think this method will work for you.

Option Explicit

Public Sub FindDuplicates()

    Dim MyRange As Range
    Dim Cell As Range
    Dim CountOfDuplicate As Long

    Set MyRange = ActiveSheet.Range("A1").CurrentRegion

    For Each Cell In MyRange
        CountOfDuplicate = Application.WorksheetFunction.CountIf(MyRange, "=" & Cell)
        If CountOfDuplicate > 1 And InStr(1, Cell, "<<<") > 0 Then
            Cell.Interior.Color = RGB(200, 200, 200)
        End If
    Next Cell

End Sub

The above procedure will test each cell in the CurrentRegion for the partial string <<< and a CountIfs result greater than 1 and color the interior of the cells gray. Let me know if this does the trick for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM