Get RGB codes of a cell color

Post Reply
wwj
Posts: 2497
Joined: 27 Jan 2007 08:16

Get RGB codes of a cell color

Post by wwj »

Get RGB codes of a cell color
- use the function below.

Code: Select all


Function GetRGBColor(cell As Range) As String
    Dim colorVal As Long
    Dim redVal As Integer, greenVal As Integer, blueVal As Integer

    colorVal = cell.Interior.Color
    redVal = colorVal Mod 256
    greenVal = (colorVal \ 256) Mod 256
    blueVal = (colorVal \ 65536) Mod 256

    GetRGBColor = "RGB(" & redVal & ", " & greenVal & ", " & blueVal & ")"
End Function


Post Reply