Need to put leading 0s back

i.beard

New Member
Joined
Feb 12, 2009
Messages
13
I have a group of #s, some had leading 0s some did not. They should all be 11 digits however even though the column is formatted as text, it took the leading 0s off. I know there is a formula to put them back I just can't figure out what it is...
For instance if the length of a2 = 10 add "0" at the beginning of the #.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Thank you for your reply.

=IF(LEN(A2)=10,"0"&A2,IF(LEN(A2)=9,"00"&A2,IF(LEN(A2)=88,"000"&A2,"NA")))

Was what I was looking for I think.
 
Upvote 0
Looking at your formula it seems that you don't want numbers with less than 8 digits.

In that case you can also use:

=IF(LEN(A1)>=8,TEXT(A1,"00000000000"),"NA")
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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