【问题标题】:Highlight cells with duplicate values, but each duplicate value a unique color. Excel Conditional Formatting突出显示具有重复值的单元格,但每个重复值都具有唯一的颜色。 Excel 条件格式
【发布时间】:2020-10-02 21:44:36
【问题描述】:

基本上,我想突出显示所有具有重复值的重复单元格。我已经使用条件格式来做到这一点。不同之处在于,我希望每个不同的重复值都以独特的颜色突出显示。

例如, 如果在三个不同的单元格中发现了苹果,则将它们全部突出显示为红色。 如果在两个不同的单元格中发现橙色,则将它们全部设为蓝色 等等等等,这将持续数百个不同的重复值......所以我需要它来生成稍微独特的颜色。

有什么想法吗?谢谢!

编辑:我在这个网站上找到了一个解决方案:https://www.extendoffice.com/documents/excel/3772-excel-highlight-duplicate-values-in-different-colors.html 虽然安装这个模块需要花钱,所以如果有人有不同的解决方案,我将不胜感激。

【问题讨论】:

  • 您可以通过发布并接受您自己的答案来关闭此问题。不建议删除。最好在此处发布答案中的解决方案,而不仅仅是一个链接。

标签: excel duplicates formatting conditional-statements highlight


【解决方案1】:

我找到了一个使用 KUTOOLS 的解决方案,可以在以下网站上找到: https://www.extendoffice.com/documents/excel/3772-excel-highlight-duplicate-values-in-different-colors.html

在VBA中插入一个模块并输入以下代码:

Sub ColorCompanyDuplicates()
'Updateby Extendoffice 20160704
Dim xRg As Range
Dim xTxt As String
Dim xCell As Range
Dim xChar As String
Dim xCellPre As Range
Dim xCIndex As Long
Dim xCol As Collection
Dim I As Long
On Error Resume Next
If ActiveWindow.RangeSelection.Count > 1 Then
  xTxt = ActiveWindow.RangeSelection.AddressLocal
Else
  xTxt = ActiveSheet.UsedRange.AddressLocal
End If
Set xRg = Application.InputBox("please select the data range:", "Kutools for Excel", xTxt, , , , , 8)
If xRg Is Nothing Then Exit Sub
xCIndex = 2
Set xCol = New Collection
For Each xCell In xRg
  On Error Resume Next
  xCol.Add xCell, xCell.Text
  If Err.Number = 457 Then
    xCIndex = xCIndex + 1
    Set xCellPre = xCol(xCell.Text)
    If xCellPre.Interior.ColorIndex = xlNone Then xCellPre.Interior.ColorIndex = xCIndex
    xCell.Interior.ColorIndex = xCellPre.Interior.ColorIndex
  ElseIf Err.Number = 9 Then
    MsgBox "Too many duplicate companies!", vbCritical, "Kutools for Excel"
    Exit Sub
  End If
  On Error GoTo 0
Next
  End Sub

然后按 F5 运行模块。

注意:这仅适用于安装了 KUTOOLS)

【讨论】:

  • 对我来说看起来像 Kutools 营销!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-06-13
  • 2021-09-16
  • 1970-01-01
  • 2016-09-07
  • 2020-05-20
  • 2022-12-15
  • 2019-10-21
相关资源
最近更新 更多