[Solved] Formatting output according to value

Discuss the spreadsheet application
Post Reply
JohnPowers
Posts: 2
Joined: Tue Jun 01, 2021 9:06 pm

[Solved] Formatting output according to value

Post by JohnPowers »

Hi there, wise ones! I hope someone can help me with a rather obscure request I got from a client I do some occasional stuff for. They would like to have the output format in their spreadsheet dependant on the value in the cell. I have no idea how to do this, or even if it is possible! So for instance, what they want me to do is to stick in, say cell D4, a value like:

=IF(A4 < 10; "Y"[in green]; "N"[in red] )

Is this even possible? If not, can anybody think of a clever workaround to achieve a similar looking effect? Thanks for any help - John
Last edited by robleyd on Wed Jun 02, 2021 12:34 pm, edited 2 times in total.
Reason: Add green tick
openoffice 4.1.7 - windows 10
FJCC
Moderator
Posts: 9277
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Formatting output according to value

Post by FJCC »

You do this sort of thing with conditional formatting. In the attached file, I defined two cell styles called red and green that differ from the Default style only in the font color. I applied the red style to D4. I set up conditional formatting on the cell (menu Format -> Conditional Formatting) to apply the green style if the cell value is "Y". The formula in D4 controls whether the cell shows an N or a Y.
There are many possible variations on that strategy.
Attachments
CondFormatting.ods
(8.07 KiB) Downloaded 82 times
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Formatting output according to value

Post by Villeroy »

Since you are using an IF formula anyway, you can combine it with function STYLE.
In FJCC's file:

Code: Select all

=IF(A4 < 10; "Y"&T(STYLE("green")); "N"&T(STYLE("red")))
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
JohnPowers
Posts: 2
Joined: Tue Jun 01, 2021 9:06 pm

Re: [Solved] Formatting output according to value

Post by JohnPowers »

This does it - huge thanks.. I followed FJCC's advice and it does exactly what I needed here. In fact, by then I had it fixed, before I noticed Villeroy's additional short cut, but I will keep that in mind if I get a similar request. So thanks to both of you for taking the time to respond. - John
openoffice 4.1.7 - windows 10
Post Reply