Text format for numbers to preserve trailing zeros

KonEd

New Member
Joined
Mar 19, 2024
Messages
3
Platform
  1. Windows
Hi All,
I am a newcomer here. I found an old question which I am interested to.
I ask anybody to write a Sub file to apply this Function published there:
=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))
Thanks in advance.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Welcome to the Board!

I am not sure if that is necessary. You may be able to do it easier with the TEXT function.
But can you explain EXACTLY what you are trying to do, and show us a few examples of your data and expected output?

And when you say "write a Sub file", do you mean that you are looking for a VBA solution instead of an Excel formula?
What if it is a very simple Excel formula (not like the one you posted above)?
 
Upvote 0
If all you need is 2DP and a total length of 10 including padded spaces, then:

Excel Formula:
=LEFT(TEXT(A1,"0.00          "),10)
 
Upvote 0
Welcome to the Board!

I am not sure if that is necessary. You may be able to do it easier with the TEXT function.
But can you explain EXACTLY what you are trying to do, and show us a few examples of your data and expected output?

And when you say "write a Sub file", do you mean that you are looking for a VBA solution instead of an Excel formula?
What if it is a very simple Excel formula (not like the one you posted above)?
Thanks for your helpfulness

I have Excel tables containing thousands lines with text and number cells. Part of it is enclosed below. I need convert the table into a plain text file. Simple copy/paste method results in disordered layout of columns due to omitting of trailing zeros in number cells by default. So it gives a lot of manual work.

I am going to write a VBA Macro Sub to add necessary trailing zeros in a resulting file arising from separate number columns. After that I would combine all the text columns into a general text table using the Multiedit package.

I suppose to have some simple form in my Sub to insert the column name, its width and the number of digits.
 

Attachments

  • Im_cr.jpg
    Im_cr.jpg
    88.5 KB · Views: 12
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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