| View previous topic :: View next topic |
| Author |
Message |
Gecopah Newbie

Joined: 06 Mar 2012 Posts: 3
|
Posted: Tue Mar 06, 2012 9:20 am Post subject: Adding text to formula changes cell format |
|
|
Hello....I was hoping someone may be a able to comment on a problem I am having with displaying results in a cell. My original cell displays the results of two different formulas and one string of text.
I have simplified the formula and text to demonstrate the problem as it still occurs with only one formula and one string of text.
As an example with say cell C1 having a value entered of 5.5
If my formula of cell A1 is:
= 1 + C1
...and the number format code for cell A1 is set to 0, I get the result of 7 ( which is what I want - rounding up/down)
However if I add text to that formula, the result is such that I get the decimal result of 6.5 displayed in the cell even if the cell number format is set to 0:
= "The result is " & ( C1 + 1 ) |
|
| Back to top |
|
 |
range General User

Joined: 04 Jan 2012 Posts: 21
|
Posted: Tue Mar 06, 2012 9:29 am Post subject: |
|
|
That is because the cell will ignore the number format if it has text content.
Try...
= "The result is " & TEXT(( C1 + 1 );"0") |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Tue Mar 06, 2012 9:35 am Post subject: |
|
|
You must not believe that any format attribute has any influence on your cell value. The cell value remains 6.5 even when you format that number as date+time which gives January 5th 12:00PM or percent (650%), currency, fraction or whatever. It remains 6.5.
If you want 7 then use ROUNDUP(6.5) and the cell value will be 7.
A text value does not have any number format at all and concatenation always gives text. Concatenated numbers are converted to plain unformatted decimal. Function TEXT converts a number to text to be displayed in a given number format. _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org
Last edited by Villeroy on Tue Mar 06, 2012 1:51 pm; edited 1 time in total |
|
| Back to top |
|
 |
Gecopah Newbie

Joined: 06 Mar 2012 Posts: 3
|
Posted: Tue Mar 06, 2012 9:42 am Post subject: |
|
|
| Thank you Villeroy and range...both suggestions work for me but I went with ranges since this will automatically round up or down; which ever one it is closer too. |
|
| Back to top |
|
 |
range General User

Joined: 04 Jan 2012 Posts: 21
|
Posted: Tue Mar 06, 2012 11:57 am Post subject: |
|
|
| As Villeroy says, formatting only changes how a cell displays its contents, if you use that number cell again it will have a value of 6.5 even though it displays 7. |
|
| Back to top |
|
 |
Gecopah Newbie

Joined: 06 Mar 2012 Posts: 3
|
Posted: Tue Mar 06, 2012 1:53 pm Post subject: |
|
|
| Thanks range...yeah..that actually works out perfectly that way for my purposes. |
|
| Back to top |
|
 |
|