I have a column "HEX" and three columns "R", "G", and "B".
How can I convert a HEX to RGB, e.g. ff0000
to R=255
, G=0
, and B=0
?
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 ff
to 255
and 00
to 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:
=HEX2DEC(A1)
Where cell A1
contains the string FF
, this will return 255
.