Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel: Keep trailing zero for integers, drop for all other numbers

Status
Not open for further replies.

solid7

Technical User
Apr 17, 2005
70
US
So, I am trying to write a quick way to format metric fastener pitches in a table. The values are converted to a string, as I'm outputting a completely descriptive size, based on the input parameters. The problem I'm encountering is that I can't find a way to force Excel to drop all trailing zeroes EXCEPT in the case of integers, where I want them to display to one place.

So, IF a value is an integer, THEN, display X.0

ELSE, normal behavior for general numbers. (1.2, 1.37, etc)

How might I accomplish this?

Thank you.
 
Hi,

Assuming that the value is in A1...
[tt]
=IF(INT(A1)=A1,TEXT(A1,"#.0"),TEXT(A1,"@"))
[/tt]

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Alternative formula (hope that thereis sufficient number of #s):
[tt]=TEXT(VALUE(A1),"0.0#################")[/tt]
If in A1 you have value, replace VALUE(A1) by A1.

combo
 
Thanks, SkipVought. Worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top