Text format for numbers to preserve trailing zeros

spectraflame

Well-known Member
Joined
Dec 18, 2002
Messages
829
Office Version
  1. 365
Platform
  1. Windows
I have a column of numeric values (####.##) that I need to convert to text. However when it is converted to text the trailing zeros after the decimal also need to be retained. These digits are going to be combined with other text fields in a single text string to create a TXT file to then upload.

So 4681.98 would be 4681.98
and 4326.20 would be 4326.20

I have tried using a custom format of 0000.00 however when I attempt to join that with the other values, the trailing zeros are dropped.

The end result also must be 10 characters in length. The value must be left justified with the extra spaces after the last decimal place. I have tried using =LEFT(C1&REPT(" ",10),10) however when trying it with the value of 4326.20 the result is 4326.2

Any suggestions on what I am missing?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
The magical if statement. Basically just see if it needs an ending zero. If it does, add one in.

Code:
=IF(LEN(RIGHT(C1,LEN(C1)-FIND(".",C1)))<3,LEFT(C1&0&REPT(" ",10),10),LEFT(C1&REPT(" ",10),10))
 
Upvote 0
How about:

=IF(LEN(RIGHT(C1,LEN(C1)-FIND(".",C1)))<2,LEFT(C1&0&REPT(" ",10),10),LEFT(C1&REPT(" ",10),10))

The <3 would add a 0 at the end???
 
Upvote 0
When I use the original formula you posted on a value like 4136.00, I get #VALUE!
 
Upvote 0
When I use the original formula you posted on a value like 4136.00, I get #VALUE!

That's an easy enough fix. My formula assumed that all values had a decimal. So, in the case that they don't.....
Code:
=IFERROR(IF(LEN(RIGHT(C1,LEN(C1)-FIND(".",C1)))<3,LEFT(C1&0&REPT(" ",10),10),LEFT(C1&REPT(" ",10),10)),LEFT(C1&".00"&REPT(" ",10),10))
 
Upvote 0

Forum statistics

Threads
1,215,663
Messages
6,126,097
Members
449,291
Latest member
atfoley16

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top