PDA

View Full Version : RGB (R, G, B) to hex function



stevenr
07-14-2011, 08:13 PM
Could somebody help me with a function for excel that converts RGB to hex color value? For example '255, 218, 0' to 'FFDA00'. Thank you in advance for your help.

Aflatoon
07-15-2011, 12:06 AM
Try:



Function HexRGB(R As Byte, G As Byte, B As Byte) As String
HexRGB = Right("0" & Hex(R), 2) & Right("0" & Hex(G), 2) & Right("0" & Hex(B), 2)
End Function