寻找一种方法来突出显示不同颜色的数据集中的重复项

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

我想突出显示各列的重复内容,但为了保持一切正确,如果能够以不同的颜色突出显示每个副本,那将是惊人的。

即如果12345出现在第2,4和8列,23456出现在1,2和4,那么我想在所有位置都用红色突出显示12345,在所有位置用23456突出显示黄色。 理想情况下,每个后续的副本也需要以新的颜色突出显示。

我想知道是否有任何方式来使用内置的function在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 

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