Is it possible to have a formula inside a cell's contents automatically determine if the output will be displayed in Bold, underlined, or regular print?
I can't figure out how to have calc determine whether a text string resides in a certain cell range (with VLOOKUP), and if it does, calculate a value that is printed in bold. And if the text string is not found in the cell range, have it calculate a value that is printed in regular text.
-Rob
Conditional Formatting from within a formula??
-
- Posts: 19
- Joined: Mon Aug 03, 2009 8:32 pm
Conditional Formatting from within a formula??
OpenOffice 2.4.1 on Ubuntu 8.04
NeoOffice 3.2.1 Patch 8 on Mac OSX Version 10.7.4
NeoOffice 3.2.1 Patch 8 on Mac OSX Version 10.7.4
Re: Conditional Formatting from within a formula??
You can apply a style to a cell from within a formula using the STYLE function.
First you have to define any new styles using Format->Styles and Formatting. You right click on one of the styles listed in the Styles and Formatting window, select New and then set it up however you want, including giving it a name. Let's say you call the new style Bold and you use the Default style if the text is not found.
To search for the text in the cell range, it might be easier to use the Countif function. The IF formula below sets the cell value to 1 and the style to Bold if one or more of the cells in the range A3:A13 contains "Search Text". If Search Text is not in the range it sets the cell value to 0 and the style to Default.
First you have to define any new styles using Format->Styles and Formatting. You right click on one of the styles listed in the Styles and Formatting window, select New and then set it up however you want, including giving it a name. Let's say you call the new style Bold and you use the Default style if the text is not found.
To search for the text in the cell range, it might be easier to use the Countif function. The IF formula below sets the cell value to 1 and the style to Bold if one or more of the cells in the range A3:A13 contains "Search Text". If Search Text is not in the range it sets the cell value to 0 and the style to Default.
Code: Select all
=IF(COUNTIF(A3:A13;"=Search Text")>0;1+STYLE("Bold");2+STYLE("Default"))
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.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Conditional Formatting from within a formula??
Just curious: I wonder why you want to do it in the cell's formula and not as a conditional formatting? This sounds like exactly what conditional formatting is for, without the complication of getting rid of the zero value returned by the function.
You can use STYLE() to apply a style from the conditional formatting formula, same as from the cell formula, allowing you to use as many different styles as you want.
You can use STYLE() to apply a style from the conditional formatting formula, same as from the cell formula, allowing you to use as many different styles as you want.
AOO4/LO5 • Linux • Fedora 23