Adding leading zeros to numbers which aren't the same length in the same column?

TheJay

Active Member
Joined
Nov 12, 2014
Messages
364
Office Version
  1. 2019
Platform
  1. Windows
Hello there, I have thousands of numbers that are missing zeros. I tried custom formatting 000000, but then noticed some of the numbers aren't as long, so it adds two zeros when only one is needed. Can someone please tell me the best way to ensure that whether the number is four, five or six digits long, it only adds one zero to the start? For example, from 6101 to 06101 or 61011 to 061011.

Thank you!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Do you always need to add a 0 at the start? If so, you could use "0"0 as the format
 
Upvote 0
Solution
Thank you, that's exactly what I needed. Can you please explain how that works?
 
Upvote 0
The "0" is a literal 0 that is added regardless of the number in the cell. The 0 just reflects a placeholder of at least one number.
 
Upvote 0
That's really well explained, thank you. So it would work on any number that is at least one digit long. I've always wondered about stuff in quotes under custom formatting.
 
Upvote 0
The 0 means that you will always get at least 0 displayed. The fact that there is no decimal point or decimal placeholders means that any decimal places will be rounded - eg 0.4 would show as 0, and 0.5 as 1 - and then the literal 0 will be prepended to that. So 0.4 would show as 00 in the cell.

Anything you put in quotes (or you can use \ for single characters, so \00 would also work, but I find "0"0 clearer ) is literal text and will appear in the cell exactly as typed.

It's worth having a quick read of this: Number format codes
 
Upvote 0

Forum statistics

Threads
1,215,009
Messages
6,122,674
Members
449,091
Latest member
peppernaut

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