如何使用单元格内的十六进制颜色值突出显示单元格(但对于 Excel 的最新版本)

How to highlight a cell using the hex color value within the cell (but for the latest edition of Excel)

我想尝试为彩色物品收集数据库创建电子表格。如果当我输入十六进制代码时,其中包含十六进制代码的单元格填充的颜色与十六进制相同,那将非常有用。这样我就可以比较不同颜色的物品并混合搭配外观相似的颜色。 Spreadsheet currently looks like this

如果有人知道如何将十六进制列中的单元格填充为与单元格中写入的十六进制颜色相同的颜色,请告诉我!

Option Explicit

Sub ChangeSelectedCellsBackground()
    Dim cell
    For Each cell in Selection
        ChangeCellBackground cell
    Next
End Sub

Sub ChangeCellBackground(cell)
    Dim hexStr as string
    hexStr = cell.Value

    Dim r as string
    Dim g as string
    Dim b as string
    r = Mid(hexStr, 1, 2)
    g = Mid(hexStr, 3, 2)
    b = Mid(hexStr, 5, 2)
    
    cell.Interior.Color = RGB(CInt("&H" & r), CInt("&H" & g), CInt("&H" & b))
End Sub