Conditional Formatting - on decimal place values?

Discuss the spreadsheet application
Post Reply
User avatar
Adendum
Posts: 7
Joined: Mon Jul 05, 2010 6:51 pm

Conditional Formatting - on decimal place values?

Post by Adendum »

Is it possible to set up conditional formatting on cell values so that if the calculated value is not a whole number (e.g. 123.00) the formatting changes.

I am trying to highlight only those values that are whole numbers and want to 'hide' or even not show any values that are not whole numbers.

:D
OpenOffice 3.3.0. on Vista Home Premium 64bit.
FJCC
Moderator
Posts: 9623
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Conditional Formatting - on decimal place values?

Post by FJCC »

You can set the conditional formatting to use a formula

Code: Select all

MOD(A1;1) = 0
This will flag cells that contain exact integers. If the cell contents are the results of a calculation, you will want to embed the ROUND function so that rounding problems don't cause errors. For example, limiting the precision to 4 decimal places:

Code: Select all

MOD(ROUND(A1;4);1) = 0
You can set the formatting so that cells that fail the test use a font color that matches the background, so they will appear empty.
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
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Conditional Formatting - on decimal place values?

Post by Charlie Young »

Adendum wrote:Is it possible to set up conditional formatting on cell values so that if the calculated value is not a whole number (e.g. 123.00) the formatting changes.

I am trying to highlight only those values that are whole numbers and want to 'hide' or even not show any values that are not whole numbers.

:D
Just create a cell style, say "HideNumber," with the font color the same as the background color. In conditional formatting then, choose "Formula is" instead of "Cell value is," enter as the formula cell<>INT(cell) (where cell is the address of the cell you're formatting) and apply that style, and then also you can create some style for your whole numbers, and apply it with the formula cell=INT(cell). There would be some other niceties if you want to check if the cell contains a string and so forth. Note that the font color trick only hides the value in the cell; it still shows on the input line.
 Edit: Too slow, but either way will work. 
Apache OpenOffice 4.1.1
Windows XP
Post Reply