I have a column “HEX” and three columns “R”, “G”, and “B”.
How can I convert a HEX to RGB, e.g.
I know that the first 2 characters
ff belongs to “R”, the next 2
00 belongs to “G”, and the final 2
00 belongs to “B”. So I will have to use
=LEFT(A1, 2) for “R”,
=RIGHT(LEFT(A1, 4), 2), and
=RIGHT(A1, 2) for the last.
But how can I convert
0, etc.? I guess I will have to do something to parse from hexadecimal (base 16) to decimal (base 10)?
I would like to do it without VBA.
You can convert from hex to decimal using the
HEX2DEC() function. For instance:
A1 contains the string
FF, this will return
You can try with the
=Hex2Dec(A1) indeed, but you should split its input into 3 parts:
One for R, one for G and one for B, considering that you would always get them in a format like this ff0000.
This is the result from the formula:
Some pages make that (w3SCHOOL PICKER), but in excel you can make this
If you try without vba, you’ll only can use 56 colors.
(in case use the colors from a cell)
I have managed to create a excel spreadsheet that converts Hex to RGB in three columns; Red, Green and Blue. Below is the code for it:
So far, I have not found any restrictions to this code.
I also made code for RGB to hex:
I hope this answers your question.