dj44
02-27-2017, 05:54 AM
Hi folks,:)
I am having some rgb hex trouble
This hex color is gray #C7C7C7 -
- but it displays as green - a lot of colors are displayed wrong as well from the hex side.
I am testing the display color in excel.
I read somewhere that excel displays it as BGR
Sub DisplayHexColorsinCell()
'Converts Hex to RGB Colors - Display Color in Column E Hex numbers in column D
Dim i, LastRow
LastRow = Range("D" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
Cells(i, "E").Interior.Color = HEXCOL2RGB(Cells(i, "D"))
Next
End Sub
Public Function HEXCOL2RGB(ByVal HexColor As String) As String
Dim Red As String, Green As String, Blue As String
HexColor = Replace(HexColor, "#", "")
Red = Val("&H" & Mid(HexColor, 1, 2))
Green = Val("&H" & Mid(HexColor, 3, 2))
Blue = Val("&H" & Mid(HexColor, 5, 2))
'HEXCOL2RGB = RGB(Red, Green, Blue)
HEXCOL2RGB = "(" & Red & "," & Green & "," & Blue & ")"
End Function
i found many hex colors here to test
http://cloford.com/resources/colours/500col.htm
Apparantly it displays in excel as BGR, and I cant work out what this means
I just want to display the correct hex color in the cell so i know its the right color as i saw on the web
I am having some rgb hex trouble
This hex color is gray #C7C7C7 -
- but it displays as green - a lot of colors are displayed wrong as well from the hex side.
I am testing the display color in excel.
I read somewhere that excel displays it as BGR
Sub DisplayHexColorsinCell()
'Converts Hex to RGB Colors - Display Color in Column E Hex numbers in column D
Dim i, LastRow
LastRow = Range("D" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
Cells(i, "E").Interior.Color = HEXCOL2RGB(Cells(i, "D"))
Next
End Sub
Public Function HEXCOL2RGB(ByVal HexColor As String) As String
Dim Red As String, Green As String, Blue As String
HexColor = Replace(HexColor, "#", "")
Red = Val("&H" & Mid(HexColor, 1, 2))
Green = Val("&H" & Mid(HexColor, 3, 2))
Blue = Val("&H" & Mid(HexColor, 5, 2))
'HEXCOL2RGB = RGB(Red, Green, Blue)
HEXCOL2RGB = "(" & Red & "," & Green & "," & Blue & ")"
End Function
i found many hex colors here to test
http://cloford.com/resources/colours/500col.htm
Apparantly it displays in excel as BGR, and I cant work out what this means
I just want to display the correct hex color in the cell so i know its the right color as i saw on the web