| View previous topic :: View next topic |
| Author |
Message |
Alwyn@SparepennyLa General User

Joined: 08 May 2010 Posts: 19
|
Posted: Thu Jun 28, 2012 3:15 am Post subject: IF function |
|
|
Is it possible to specify a logical function dependent on colour (Brit. Eng)?
Example:
If the specified cell has red text because it's formatted to be red for a negative figure I want the text in the current cell to be red instead of black. |
|
| Back to top |
|
 |
karolus OOo Advocate

Joined: 22 Jun 2011 Posts: 208
|
Posted: Thu Jun 28, 2012 4:46 am Post subject: |
|
|
Hallo
→Format→Conditional Formating still exists !
Karo |
|
| Back to top |
|
 |
Alwyn@SparepennyLa General User

Joined: 08 May 2010 Posts: 19
|
Posted: Thu Jun 28, 2012 7:01 am Post subject: |
|
|
Thanks Karo but I'm not sure how to make a condition dependent on another cell. I already have conditional formatting in the adjacent cell that shows figures in red in brackets if the figure is negative.
Currently, if the adjacent cell is empty then nothing shows; if there is an entry (figures) then £ (Sterling) appears. What I want to do is make the £ sign red if the figures in the adjacent cell are negative. |
|
| Back to top |
|
 |
keme Moderator


Joined: 30 Aug 2004 Posts: 2744 Location: Egersund, Norway
|
Posted: Fri Jun 29, 2012 12:47 am Post subject: |
|
|
You can't easily extract applied colour for use in formulas, but if that colour is based on a condition you can use the original dependency again.
If this is needed only for display purposes (i.e. you don't need to extract that £ sign from the cell), you can repeat the value and use formatting to display the £ sign. It's a bit "quick and dirty" solution, but should work also if exported to other spreadsheet formats.
Explicitly, assuming that your amount is in cell D2 and you need the £ sign in C2:
Formula in C2: =D2
Format string for C2: "£";[RED]"£";"";""
The above will not distinguish zero and empty cells, so if you have entries with a "zero amount" it will not display the pound sign. A bit more elaborate construct to handle that:
Formula in C2: =IF(ISNUMBER(D2);D2;"")
Format string for C2: "£";[RED]"£" |
|
| Back to top |
|
 |
Alwyn@SparepennyLa General User

Joined: 08 May 2010 Posts: 19
|
Posted: Fri Jun 29, 2012 3:50 am Post subject: Logical function dependant on colour |
|
|
Many thanks keme, most helpful.
I guess in that case that it would also be possible to take this further and include underlining and bold if it's in the next cell. I think that's probably an unnecessary refinement though. |
|
| Back to top |
|
 |
keme Moderator


Joined: 30 Aug 2004 Posts: 2744 Location: Egersund, Norway
|
Posted: Tue Jul 10, 2012 2:30 am Post subject: Re: Logical function dependant on colour |
|
|
| Alwyn@SparepennyLa wrote: | Many thanks keme, most helpful.
I guess in that case that it would also be possible to take this further and include underlining and bold if it's in the next cell. |
Not directly, no.
My suggestion does not use the format of the source cell, but "recycles" the condition causing that format. Specifically, instead of asking "is C2 printed in red?" we ask "is C2 holding a negative number?", then assign the red colour based on that.
Like I said, you can't easily extract cell colour, and that also goes for other formatting elements (like bolding and underlining).
I have seen mentions of extensions that enable such extraction, but I haven't used them so I do not know how they will affect portability and robustness for your spreadsheet (i.e. how they behave when opened in a different computer, or when you upgrade your own software). |
|
| Back to top |
|
 |
Alwyn@SparepennyLa General User

Joined: 08 May 2010 Posts: 19
|
Posted: Tue Jul 10, 2012 8:05 am Post subject: Re: Logical function dependant on colour |
|
|
| keme wrote: | | Alwyn@SparepennyLa wrote: | Many thanks keme, most helpful.
I guess in that case that it would also be possible to take this further and include underlining and bold if it's in the next cell. |
Not directly, no.
My suggestion does not use the format of the source cell, but "recycles" the condition causing that format. Specifically, instead of asking "is C2 printed in red?" we ask "is C2 holding a negative number?", then assign the red colour based on that.
Like I said, you can't easily extract cell colour, and that also goes for other formatting elements (like bolding and underlining).
I have seen mentions of extensions that enable such extraction, but I haven't used them so I do not know how they will affect portability and robustness for your spreadsheet (i.e. how they behave when opened in a different computer, or when you upgrade your own software). |
Many thanks for this. It explains the process. As far as portability is concerned it's bad enough saving an ods document as an xls document or an odt doc as a doc document either of which seem to give rise to formatting problems for MS Office users. For that reason we tend to send them out as pdfs. |
|
| Back to top |
|
 |
|