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

PHOTO EMBED

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

Saved by @baamn #vb

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If (Left(ActiveCell.Text, 1) = "#" And Len(ActiveCell.Text) = 7) Then
    ActiveCell.Interior.Color = WorksheetFunction.Hex2Dec(Mid$(ActiveCell.Text, 2))
End If

End Sub
content_copyCOPY

This is another option - it updates the cell color when you select the cell assuming the value in the cell starts with "#" and is 7 characters.

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