Updated August 21, 2023
Introduction to Leading Zeros in Excel
Leading Zeros in Excel are used where keeping zeroes at the start of the numbers is required, so the number system format will not change. However, while working, we may see some situations where if we paste some numbers of selected columns to another file, if those numbers have zeroes at the starting, then those zeroes will get removed, as Zero has no significance at the start of any number sequence. This can be prevented by customizing the numbers in the Format Cells option.
How to Add Leading Zeros in Excel?
Adding leading Zeros in Excel is very simple and easy. Let’s understand how to add leading Zeros in Excel with some examples.
Excel Leading Zeros – Example #1
- As shown below, we have a sample list of random numbers from 10 to 40.
As we can see, all the numbers are positive and do not have any Zeros at the start. They have Zeroes at the end, which makes a valuable addition.
- First, select the number and right-click on it to add leading Zeroes in these numbers. Now, from the right-click menu, select Format Cells, as shown below.
- After that, we will get a Format Cells box.
- Now from the Category section, go to Custom, as shown below.
- Custom is the category where we can customize any defined format or create a new format as required. Here, we need to add leading Zeroes in numbers. So, as we have selected the data already with that only while selecting Custom, it has taken us to General, as shown above. So, for adding leading Zeroes for selected data, select any Zero from the list as shown below.
- Now in the Type box, edit the number of leading Zeroes as per requirement. For example, here we have added 3 Zeroes as the numbers we selected are 2nd digit numbers. So the 3 Zeroes in this will add only one leading Zero in the selected numbers, as shown below.
- Once we add, we will see the Sample output in the same box above the Type box. Once done, click on OK.
- We will see the leading Zeroes in the selected numbers after that, as shown below.
Excel Leading Zeros – Example #2
Another method is where the leading zeroes from any file or table may be removed. For example, suppose we face a situation where we need to import data from any notepad file. And in that file, data already has leading zeros, as shown below.
Data in the Notepad file is always in the text. So there is no impact if we keep data; there is a simple format. But when we import this data to Excel, the column named Product Numbers with leading Zeroes may get converted into number format. As zeroes at the start mean nothing, if it is a number, it will be removed automatically. To avoid this, select the Delimited option as shown below while importing the data from the Text file and click Next.
- Now check the Delimiters as Tab and click on Next.
- And in the third step, select complete data first as in format select text to finish the process by pressing Shift + Ctrl + Left clicks. And click on Finish to complete it.
- Now another window will come up. From there, select the reference cell for importing the data and click on Ok once done.
- Once we finish the process, we will get the output of our imported data in text format, as shown below.
We can use this data anywhere, the format will be the same, and it will not eliminate leading Zeroes. If it is required to change the Product number format from text to numbers, this can be done in Format Cell under the Custom category, which we have seen in example-1.
Pros of Leading Zeros in Excel
- Adding leading Zeroes in numbers is required to make data in a uniform format.
- There might be a situation where you may get data in different number lengths, but to make it equal, if we add the same number of Zeroes, the length will equal all the selected numbers. This properly formats the data.
Cons of Leading Zeros in Excel
- In adding leading Zeroes when we import the data, it will no longer be used for numbering functions if the data gets converted into text.
Things to Remember
- While importing the data from any file to Excel, if you convert the data into text, then later, you again need to convert that data into a number by using a custom category for adding leading Zeroes.
- In format pasting the data, leading zeroes will be removed, so avoid doing so if your selected data is already in the text. There is no problem if we format+ paste converted numbers into text in another format or file. It will remain as it is without changing the format.
Recommended Articles
This has been a guide to Leading Zeros in Excel. Here we discuss adding leading zeros in Excel, excel examples, and a downloadable Excel template. You can also go through our other suggested articles to learn more –