Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are Excel RGB values backwards? [closed]

Tags:

excel

hex

rgb

vba

This function is an example. Note that the RGB values are actually BGR values. Why does excel do this?

 Function GetRGB(ByVal cell As Range) As String

 Dim R As String, G As String
 Dim b As String, hexColor As String
 hexCode = Hex(cell.Interior.Color)

 'Note the order excel uses for hex is BGR.
 b = Val("&H" & Mid(hexCode, 1, 2))
 G = Val("&H" & Mid(hexCode, 3, 2))
 R = Val("&H" & Mid(hexCode, 5, 2))

 GetRGB = R & ":" & G & ":" & b
 End Function
like image 718
iliketocode Avatar asked Oct 28 '25 04:10

iliketocode


1 Answers

Excel RGB values are not backwards, actually Excel or in a broader sense, windows uses BGR color model.

Reference links:

a. link1 b. link2 c. link3

like image 188
ZAT Avatar answered Oct 31 '25 02:10

ZAT