You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openoffice.apache.org by "Itipong (Paul)" <ip...@gmail.com> on 2016/11/14 06:39:15 UTC

A question

Dear Sir or Madam

I would like to know if I can change the font color by using IF Function as an example below.

                            =if((a1+b1)<5;red(a1+b1);green(a1+b1))

I cannot find a solution or an example on the OpenOffice Help.  So please advise.

Your assistance is much appreciated.

Sincerely,
Paul

Re: A question

Posted by Regina Henschel <rb...@t-online.de>.
Hi Paul,

Itipong (Paul) schrieb:
> Dear Sir or Madam
>
> I would like to know if I can change the font color by using IF Function as an example below.
>
>                              =if((a1+b1)<5;red(a1+b1);green(a1+b1))
>
> I cannot find a solution or an example on the OpenOffice Help.  So please advise.
>
> Your assistance is much appreciated.

Besides the way Brian has described, I know two other ways. For both you 
need to define cell styles. Define a cell style "green", where you 
select a green color in tab "Font Effects" or perhaps a green background 
or a green border. Do similar for cell style "red".

Method A: conditional formatting
Assign to all result cells the format "green".
Set cursor in result cell and use Format > Conditional Formatting.
Set the condition to "cell value is" "less than", the value to 5, and 
the style to "red".
Copy that cell.
Select all other result cells and use Edit > Paste Special. Unselect all 
but "Formats". OK

Method B: function STYLE
Use the formula =a1+b1+IF(a1+b1<5;STYLE("red");STYLE("green"))
The function STYLE results 0, so that adding it to a1+b1 will not change 
the result. The function STYLE formats the cell in which it is used with 
the style given by the style name.

Kind regards
Regina



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@openoffice.apache.org
For additional commands, e-mail: users-help@openoffice.apache.org


Re: A question

Posted by Brian Barker <b....@btinternet.com>.
At 13:39 14/11/2016 +0700, Paul Itipong wrote:
>I would like to know if I can change the font color by using IF 
>Function as an example below.
>=if((a1+b1)<5;red(a1+b1);green(a1+b1))

You probably know the answer is No! But you can achieve this 
differently but very easily. In the cell itself, just put the formula as usual:
=A1+B1
Then format the result cell or cell range:
o Go to Format | Cells... | Numbers | Format Code (or right-click | 
Format Cells... | Numbers | Format Code).
o Enter: [RED][<5]0;[GREEN]0 for the Format Code.

You can adjust the numeric format code - shown as "0" above - as 
desired, of course.

You can do more complex things using Format | Conditional 
Formatting..., but that is not necessary here.

I trust this helps.

Brian Barker


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@openoffice.apache.org
For additional commands, e-mail: users-help@openoffice.apache.org