vba - How to highlight a cell using the hex color value within the cell? - Stack Overflow

PHOTO EMBED

Wed Aug 14 2024 09:45:40 GMT+0000 (Coordinated Universal Time)

Saved by @baamn #vb

Sub ColorCellsByHex()
    Dim r
    If TypeName(Selection) <> "Range" Then Exit Sub
    For Each r In Selection
        r.Interior.Color = Abs(("&H" & Mid(r, 6, 2) & Mid(r, 4, 2) & Mid(r, 2, 2)))
    Next
End Sub
content_copyCOPY

There is no need to repeatedly pierce the VBA/Worksheet barrier to convert. This streamlined version gets the byte order correct

https://stackoverflow.com/questions/10455366/how-to-highlight-a-cell-using-the-hex-color-value-within-the-cell?rq