LibreCalc: Conditional formatting for separate ranges

I have a table in LibreCalc, where each line consists of two cells (to keep it simple).

For each line, I want to color the first cell green if and only if the second cell is not empty. How do I do that?

It seems that conditional formatting can only color the cell containing the condition, but I have one cell for coloring and a separate cell for the condition. This is no problem in Excel, but is this possible in LibreCalc?

lars

Assuming your data range is A1:B3 and A1:A3 is to be coloured depending on values in B1:B3 then select cells from A1 to A3 and as formatting condition choose Formula is and as formula enter
NOT(ISBLANK(B1))
The Cell Range where the formatting is applied to is A1:A3, with the B1 relative reference in the formula it makes that reference B2 on A2 and B3 on A3.

2 Likes

Thanks for your suggestion! I thought that this is how it works, but when I choose “Formula is …”, there is no way to enter a formula:

Given the above dialog, what do I do now?

It looks it’s a bug.
But you can set the conditional format by the macro
MacroConditionalFormat.ods (10.8 kB)

For example in B1 is some text and you want to color A1. Create your Cell Styles (or use predefined ones) and to the A1 write something like this (with the names of your cell styles)

=IF(ISBLANK(B1);T(STYLE("MyDefault"));T(STYLE("MyStyle")))

Example
cellBackground.ods (8.2 kB)

Thanks, that almost works, but I actually want to color the cell containing text.

Adding a third cell with a formula is fine, but I haven’t figured out how to do this.

Please do not recommend the use of the STYLE() function. It’s a legacy and IMHO should rather be deprecated. It sets the cell style during formula evaluation, whenever a recalc is triggered for that formula, whereas conditional formatting is evaluated for the current view only, not replacing an applied cell style. STYLE() is also not interoperable with other spreadsheet implementations. The only real use of STYLE() is to temporarily highlight a cell with a timeout along with the call of an asynchronous Add-In function when that delivers its result.

Another thing I don’t understand: Suppose you want to color the cell containing a certain value. If you choose “Cell value is” and “Equal to”, don’t you have to specify which value your cell should be equal to?

I see no way to specify a given value. Thus, if I click OK anyway, my cells just remain unmodified.

Could you please upload your file?

I believe it relates to this problem mentioned elsewhere in this thread.

I don’t seem to have this problem. Let’s look at the insides of the file, maybe we’ll see something. :slightly_smiling_face:

Yes, I seem to have a bug on Linux, see my screenshot above.

Thanks for pointing this out to me!

OK, to summarize, a lot of my issues are because I don’t see everything on the dialogs. I’ll open a bug report.