Pages

Thursday, March 1, 2012

UDF TO find RGB Value of a color

If you want to know the R G B Value of a color. Try this udf




Add the below code to the module

Function rgb_color(cl As Range) As String
Dim rgbc As Long, rc As Long, gc As Long, bc As Long
If cl.Cells.Count = 1 Then
rc = cl.Interior.Color Mod 256
rgbc = Int(cl.Interior.Color / 256)
gc = rgbc Mod 256
bc = Int(rgbc / 256)
rgb_color = "Red - " & rc & " Green - " & gc & " Blue - " & bc
Else
rgb_color = "Please select single cell only"
End If
End Function


For Example

Cell A1 is having any fill color and you want to know the R G B Value of that color.

In Cell B1 Type rgb_color(A1)

1 comment: