How to zero fill a number inside of an Excel cell
-
11-07-2019 - |
Question
How do you zero fill a number to 10 positions inside an excel spreadsheet?
i.e. If cell A1 has 1234 how can cell A2 display 0000001234 (10 postions).
Solution
=TEXT(A1,"0000000000")
OTHER TIPS
Not a programming question, really:
- Select cells you want formatted in this way.
- Right click and select "Format Cells..."
- Select the "Number" Tag, and scroll down to "Custom" in the category list.
- Type "0000000000" into the Type field.
Format>Cells...>Number>Custom>Type>0000000000
This formula is variable.
It checks the length of the value and add "0" in front
Now the lenght is 10. You can change it.
=REPT("0",10-LEN(A1))&A1
I know this is a pretty old post, but I've just came across the same problem while exporting a sql table to excel, and I found I very simple solution! Just set the cell format to ' Custom' then type the amount of characters you want the final number to have; In your case 10 positions '0000000000' I don't usually reply to the stackoverflow's posts, so I don't have enought reputation to post images;
Something like the following.
right( "0000000000" & number, 10 )
Put 10 zeroes on the left, take the right-most 10 positions, whatever they turn out to be.
Also, you have
text( number, "0000000000" )
How to display full the number inside in excel workseet?
I.e cell A1 "2.40252E+13" how to display full number in A1 became "24025207702012"