add a 0 in front of 11 digit number to equal 12

afs24

Board Regular
Joined
Sep 26, 2002
Messages
237
How can I write a formula that will add zeros in front of a number in another column if that number does not have 12 digits. For example:

My PO is: 66782379167

I want it to be 066782379167.

The number will either have 11 digits or 12 digits. If it's already 12 digits then I don't need to add a zero but if it's 11 digits I need to add the 0.

thanks
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
=IF(LEN(cell)<12,"0"&cell,cell)

the formula assumes your value to have 11 digits. If it is possible to have a shorter text, add if statements.
 
Upvote 0
=text(a1,"000000000000")

this will make it so that regardless of the size of the value of a1, it will add zeros to make it 12 char long.
 
Upvote 0
Perhaps

=TEXT(A1, REPT("0",12))
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,590
Members
449,039
Latest member
Arbind kumar

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