How to format cells in Excel to enter leading zeroes
When you’re working with numbers, leading zeroes can make all the difference in making your data more readable and organized. They can also save you lots of time and effort when you’re entering new numbers into your spreadsheet, as they allow you to type faster without needing to double-check that the number looks right with the formatting applied. Thankfully, it’s easy to format cells in Excel so that they enter leading zeroes by default; this guide will show you how!
Leading zero when the number of digits is known
If you know that a number will always have, say, six digits, you can force Excel to display leading zeroes by creating a custom cell format. To do this, select the cells you want to format and then click on Format Cells in the Home tab. In the Number tab, select Custom from the Category list and then type in 00000 in the Type box. Click OK to apply the new formatting. Now if you enter a six-digit number, it will be displayed with leading zeroes: 012 is displayed as 00012.
You may find it useful to also include two trailing zeroes so you don’t need to keep track of whether you’ve entered four or five digits. You can do that by including an asterisk (*) after your zero code. For example, *00001 formats numbers starting with one zero and *00000 formats numbers starting with two zeros.
Leading zero when the number of digits is unknown
If you want to format a cell so that it always displays a leading zero, you can use the Custom number format. This is useful when you want to display numbers such as zip codes or ID numbers, which often have a set number of digits. The custom number format consists of two parts: the first part is for how many digits are displayed after the decimal point, and the second part specifies how many zeros should be entered before any other digit. For example, if we wanted our cell formatted with three digits after the decimal point and two zeros before any other digit, we would do this: 0.00%. When using this custom number format with a column containing integers from 1-100, all cells will automatically be formatted with leading zeros and show values from 001-100. However, if the column contains a mixture of integer and non-integer values (such as fractions), only those cells displaying integers will have leading zeros; those displaying fractions will not.
Centering text with leading zeros
If you want to center text with leading zeros in Excel, you’ll need to format the cells as text first. Here’s how
- Select the cell or range of cells
- Click on Home and then click on Alignment
- Click on Center
- Click on OK .
- Press CTRL+A to select all cells in your spreadsheet
- Hold SHIFT+CTRL+R (or ALT+SHIFT+R). The letter R is for right align.
- Press Enter
- Highlight one column at a time until all columns are highlighted
- Go down to Text Direction
- and choose Right
- Repeat steps 8-11 for each column
- The text should now be centered both horizontally and vertically
Importing data with leading zeros
If you have data that includes leading zeros, you can preserve those zeros when you import the data into Excel. To do this, open your file in Excel and select the column or columns that contain the data. Right-click on the column header and select Format Cells. In the Number tab, select Text from the list of options. This will tell Excel to treat the numbers as text, which will preserve any leading zeros. You can also specify how many digits you want to display by selecting Custom. For example, if you only want two digits after the decimal point, use 0.00%.