Excel 正在寻找以不同颜色突出显示数据集中重复项的方法

Excel 正在寻找以不同颜色突出显示数据集中重复项的方法,excel,Excel,我有连续的数据列,每个列都有一个ID代码列表 我想突出显示跨列的副本,但为了保持所有内容的笔直,如果我能以不同的颜色突出显示每个副本,那将是令人惊讶的 i、 e.如果12345出现在第2、4和8列中,23456出现在第1、2和4列中,那么我希望12345在所有位置以红色突出显示,23456在所有位置以黄色突出显示。理想情况下,每个后续副本也需要以新颜色高亮显示 我想知道是否有任何方法可以使用内置功能在excel中设置此功能。如果没有,我保证我会发布一个指南,展示如何使用VBA,但我想在完成所有这

我有连续的数据列,每个列都有一个ID代码列表

我想突出显示跨列的副本,但为了保持所有内容的笔直,如果我能以不同的颜色突出显示每个副本,那将是令人惊讶的

i、 e.如果12345出现在第2、4和8列中,23456出现在第1、2和4列中,那么我希望12345在所有位置以红色突出显示,23456在所有位置以黄色突出显示。理想情况下,每个后续副本也需要以新颜色高亮显示


我想知道是否有任何方法可以使用内置功能在excel中设置此功能。如果没有,我保证我会发布一个指南,展示如何使用VBA,但我想在完成所有这些工作之前先检查一下

您可以尝试这种VBA方法

Sub ColorsDuplicateNum()
Dim Rng As Range
Dim Cel As Range
Dim Cel2 As Range
Dim Colors As Long

Set Rng = Worksheets("Sheet1").Range("A1:K500")
Rng.Interior.ColorIndex = xlNone
Colors = 3
For Each Cel In Rng
If WorksheetFunction.CountIf(Rng, Cel) > 1 And Cel.Interior.ColorIndex = xlNone Then
Set Cel2 = Rng.Find(Cel.Value, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False, SearchDirection:=xlNext)
    If Not Cel2 Is Nothing Then
        Firstaddress = Cel2.Address
        Do
        Cel.Interior.ColorIndex = Colors
        Cel2.Interior.ColorIndex = Colors
            Set Cel2 = Rng.FindNext(Cel2)

        Loop While Firstaddress <> Cel2.Address
    End If
Colors = Colors + 1
End If
Next
End Sub
Sub ColorsDuplicateNum()
变暗Rng As范围
暗淡的Cel As范围
暗淡Cel2 As范围
淡色如长
设置Rng=工作表(“表1”)。范围(“A1:K500”)
Rng.Interior.ColorIndex=xlNone
颜色=3
对于Rng中的每个Cel
如果工作表function.CountIf(Rng,Cel)>1且Cel.Interior.ColorIndex=xlNone,则
设置Cel2=Rng.Find(Cel.Value,LookIn:=xlValues,LookAt:=xlother,MatchCase:=False,SearchDirection:=xlNext)
如果不是Cel2什么都不是
Firstaddress=Cel2.地址
做
Cel.Interior.ColorIndex=颜色
Cel2.Interior.ColorIndex=颜色
设置Cel2=Rng.FindNext(Cel2)
在第一个地址Cel2.Address时循环
如果结束
颜色=颜色+1
如果结束
下一个
端接头

范围(“A1:K500”)
调整到您的单元格范围。颜色从3开始,以跳过黑色和白色。

您可以尝试这种VBA方法

Sub ColorsDuplicateNum()
Dim Rng As Range
Dim Cel As Range
Dim Cel2 As Range
Dim Colors As Long

Set Rng = Worksheets("Sheet1").Range("A1:K500")
Rng.Interior.ColorIndex = xlNone
Colors = 3
For Each Cel In Rng
If WorksheetFunction.CountIf(Rng, Cel) > 1 And Cel.Interior.ColorIndex = xlNone Then
Set Cel2 = Rng.Find(Cel.Value, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=False, SearchDirection:=xlNext)
    If Not Cel2 Is Nothing Then
        Firstaddress = Cel2.Address
        Do
        Cel.Interior.ColorIndex = Colors
        Cel2.Interior.ColorIndex = Colors
            Set Cel2 = Rng.FindNext(Cel2)

        Loop While Firstaddress <> Cel2.Address
    End If
Colors = Colors + 1
End If
Next
End Sub
Sub ColorsDuplicateNum()
变暗Rng As范围
暗淡的Cel As范围
暗淡Cel2 As范围
淡色如长
设置Rng=工作表(“表1”)。范围(“A1:K500”)
Rng.Interior.ColorIndex=xlNone
颜色=3
对于Rng中的每个Cel
如果工作表function.CountIf(Rng,Cel)>1且Cel.Interior.ColorIndex=xlNone,则
设置Cel2=Rng.Find(Cel.Value,LookIn:=xlValues,LookAt:=xlother,MatchCase:=False,SearchDirection:=xlNext)
如果不是Cel2什么都不是
Firstaddress=Cel2.地址
做
Cel.Interior.ColorIndex=颜色
Cel2.Interior.ColorIndex=颜色
设置Cel2=Rng.FindNext(Cel2)
在第一个地址Cel2.Address时循环
如果结束
颜色=颜色+1
如果结束
下一个
端接头

范围(“A1:K500”)
调整到您的单元格范围。颜色从3开始,以跳过黑色和白色。

查看基于countifs的条件格式查看基于countifs的条件格式