4

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
John Smith
  • 7,243
  • 6
  • 49
  • 61
  • http://stackoverflow.com/questions/6003324/how-do-i-get-the-corresponding-hex-value-of-an-rgb-color-in-excel-vba Simply put numbers are right to left not left to right. As to WHY microsoft did it this way... Shrug. I'm guessing it has to do with RGB R is first so it's the first numbers on the right. some crazy logic but as long as it's consistent... shrug. – xQbert Oct 01 '14 at 21:26
  • I wonder if it has anything to do with us (in most languages) reading text from left to right, but numbers increase from right to left. – Ron Rosenfeld Oct 02 '14 at 01:07

1 Answers1

4

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

Community
  • 1
  • 1
ZAT
  • 1,347
  • 7
  • 10
  • hmm.Just wanted to say that you already know what to reverse..Would not dare to refrain you from pursuing them... – ZAT Oct 03 '14 at 15:32