JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,691
- Office Version
- 365
- Platform
- Windows
I have a UDF that calculates the odds for various events. One of the formats it can use for the result is the fractional odds (5:1, 3/4, etc.). I would like to display these in the most compact form possible. That is, no trailing zeroes. Here's some sample data the results I want:
[TABLE="class: grid, width: 250"]
<tbody>[TR]
[TD="align: center"]Actual Result[/TD]
[TD="align: center"]Desired Display[/TD]
[/TR]
[TR]
[TD="align: center"]5.000/1.000[/TD]
[TD="align: center"]5/1[/TD]
[/TR]
[TR]
[TD="align: center"]2.500/1.000[/TD]
[TD="align: center"]2.5/1[/TD]
[/TR]
[TR]
[TD="align: center"]1.250/1.000[/TD]
[TD="align: center"]1.25/1[/TD]
[/TR]
[TR]
[TD="align: center"]0.667/1.000[/TD]
[TD="align: center"]0.667/1[/TD]
[/TR]
[TR]
[TD="align: center"]1.000/2.000[/TD]
[TD="align: center"]1/2[/TD]
[/TR]
[TR]
[TD="align: center"]1.000/1.250[/TD]
[TD="align: center"]1/1.25[/TD]
[/TR]
[TR]
[TD="align: center"]1.000/1.333[/TD]
[TD="align: center"]1/1.333[/TD]
[/TR]
</tbody>[/TABLE]
My thought is to format it as "0.000" and then remove trailing zeroes. Is there a better way?
[TABLE="class: grid, width: 250"]
<tbody>[TR]
[TD="align: center"]Actual Result[/TD]
[TD="align: center"]Desired Display[/TD]
[/TR]
[TR]
[TD="align: center"]5.000/1.000[/TD]
[TD="align: center"]5/1[/TD]
[/TR]
[TR]
[TD="align: center"]2.500/1.000[/TD]
[TD="align: center"]2.5/1[/TD]
[/TR]
[TR]
[TD="align: center"]1.250/1.000[/TD]
[TD="align: center"]1.25/1[/TD]
[/TR]
[TR]
[TD="align: center"]0.667/1.000[/TD]
[TD="align: center"]0.667/1[/TD]
[/TR]
[TR]
[TD="align: center"]1.000/2.000[/TD]
[TD="align: center"]1/2[/TD]
[/TR]
[TR]
[TD="align: center"]1.000/1.250[/TD]
[TD="align: center"]1/1.25[/TD]
[/TR]
[TR]
[TD="align: center"]1.000/1.333[/TD]
[TD="align: center"]1/1.333[/TD]
[/TR]
</tbody>[/TABLE]
My thought is to format it as "0.000" and then remove trailing zeroes. Is there a better way?