Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove insignificant zeros after the decimal point

Tags:

excel

I have a table of values with decimals and whole numbers. Some of the decimals have zeros two places after the decimal point (e.g. 0.60) or the two places after the decimal point are both zeros (e.g. 4.00).

How do I make sure any zeros are removed from after the decimal point? (So the aforementioned numbers would be 0.6 and 4.)

like image 412
user112947 Avatar asked Dec 26 '22 07:12

user112947


2 Answers

You need to define your own "number format". The format code you want to use is:

0.####


EDIT


The downside is you are always left with the trailing period, which cannot be handled by number formats alone. To remedy that, you can use the following function.

=SUBSTITUTE(TRIM(SUBSTITUTE(A1,"."," "))," ",".")

Results


Original  Formatted:  Trimmed:
Numbers:
===============================
17.000    17.         17
17.100    17.1        17.1
17.100    17.1        17.1
0.100     0.1         0.1


References


  1. Create a custom number format, Accessed 2014-06-25, <http://office.microsoft.com/en-ca/excel-help/create-a-custom-number-format-HP010342372.aspx>
like image 196
Cloud Avatar answered Feb 19 '23 23:02

Cloud


The General format will not show any trailing decimal zeros. Regardless of whether the number is entered manually or calculated, if the cell format is General, Excel will only show the decimals required to represent the number.

like image 22
teylyn Avatar answered Feb 20 '23 00:02

teylyn