Conditional formatting : hex or dec RGB value contained in other cell

I would like to set a cell’s color by referring to another cell’s content, such that if the referred cell contains a hexadecimal or decimal number, the colored cell would use that number as its RGB values for its color.

So instead of a 1 dimensional scale like the “Color Scale” in Conditional Formatting, this would, in a sense, be a 3D Color Scale.

Is that possible?

I apologize for missing the multiple times this question and similar ones have popped up. That said, this answer can serve as an aggregator to the others, since multiple solutions have been provided.

It has also been asked on the OpenOffice forum and some solutions were provided. A very simple one is a little add-on Hubert Lambert made:

I reupload it here and provide the steps to follow, it’s exactly the same but I just changed the file name’s extension to .ods so AskLibreOffice would let me upload it here :



  • download this ods

  • replace its extension to .oxt

  • in L.O Calc, go to Tools > Extension Manager

  • click on Add

  • select the oxt

  • restart L.O

  • type a hex RGB code code in cell A1 (with or without a hashtag)

  • in cell C1, type =BACKGROUND(B1;A1)

  • cell B1 should now be colored according to the code in A1

There are other proposed solutions in this forum topic. Feel free to check it out and if you try any, please comment down to let us know how it went on LibreOffice. I don’t really have the time or interest to try them personally since the above solution does it for me.

There’s also this solution which doesn’t seem so handy since you have to write the cell range directly in the macro :

Finally, if you’re interested, it’s possible to do it the other way around and get a color code written in a cell based on another cell’s background color: