The simplest way to add a leading zero
Excel treats numbers that start with zero as regular numbers and drops the leading zero automatically. To keep it, format the cell as Text before you type, or use a formula that converts the number to text with the zero attached. The fastest method depends on whether you have data already in the cells or are starting fresh.
If you are starting fresh, select the cells first, then format them as Text. Type your numbers with leading zeros and they will stay. If you already have numbers without leading zeros, use a formula like =TEXT(A1,"00000") to add them — the number of zeros in the quotes determines how many digits the final result will have.
Key Takeaways
- Format cells as Text before typing if you want leading zeros to stick; Excel deletes them from regular numbers automatically.
- Use the TEXT function with a pattern like "00000" to convert existing numbers and add leading zeros in a new column.
- If you format as Text after typing numbers, Excel may not recognize them as numbers anymore, which affects sorting and calculations.
- Copy and paste values to replace the original numbers once your formula adds the leading zeros correctly.
Format cells as Text before entering data
Select the cells where you want to enter numbers with leading zeros. Right-click and choose Format Cells, or press Ctrl+1 on Windows or Command+1 on Mac. In the Format Cells dialog, click the Number tab, then select Text from the Category list on the left. Click OK.
Now type your numbers with leading zeros directly into those cells. Excel will preserve them exactly as you type them. This works for zip codes, product codes, employee IDs, or any number that should start with zero. The cells are now formatted as text, so Excel treats the entire entry as text rather than a number.
Use the TEXT function to add zeros to existing numbers
If you already have numbers without leading zeros in column A, create a formula in column B to add them. Click on cell B1 and type =TEXT(A1,"00000"). Replace the five zeros with however many digits you need in the final result. For example, use "000" for three-digit codes or "0000000000" for ten-digit phone numbers.
Press Enter. The formula converts the number in A1 to text and pads it with leading zeros to match the number of zeros in your pattern. Copy this formula down the entire column by clicking B1, then dragging the small square at the bottom-right corner of the cell down to the last row with data. All numbers in column A now have leading zeros in column B.
Once the formula is working correctly, copy all the results in column B. Right-click and choose Paste Special, then select Values only. This replaces the formulas with the actual text so you can delete column A if you no longer need it.
Why Excel removes leading zeros and how to prevent it
Excel is designed to work with numbers, and numbers do not have leading zeros — the number 00123 is the same as 123. When you type a number starting with zero into a regular cell, Excel automatically converts it to a number and drops the zero. This happens instantly, even if you do not see it happening.
The only way to keep a leading zero is to tell Excel to treat the entry as text instead of a number. You can do this by formatting the cell as Text first, by typing an apostrophe before the number (like '00123), or by using a formula that returns text. Once Excel knows the cell contains text, it will not strip the leading zero.
Add a leading zero with an apostrophe
If you only have a few entries to fix, type an apostrophe directly before the number: '00123. The apostrophe tells Excel to treat everything after it as text. The apostrophe itself will not appear in the cell — only the number with its leading zero will show.
This method is quick for one-off entries but becomes tedious if you have hundreds of numbers to fix. It also does not work if you are pasting numbers from another source, because you would have to add the apostrophe to each one individually. For large datasets, the TEXT function or pre-formatting is faster.
Convert text back to numbers if you need calculations
Once cells are formatted as text, Excel will not use them in math operations the way it uses numbers. If you need to add, subtract, or sort these values as numbers later, you may need to convert them back. Select the cells, go to Data in the menu, and look for Text to Columns. Click it, then click Finish in the dialog that appears. Excel will convert the text entries to numbers while keeping the leading zeros if the cells are still formatted as Text.
Alternatively, use a formula like =VALUE(A1) to convert text to a number, though this will remove the leading zero. The choice depends on whether you need the leading zero for display or whether you need the entry to behave like a number for sorting and math.
Common mistakes when adding leading zeros
Formatting a cell as Text after you have already typed a number does not always work. If you type 123 in a regular cell and then format it as Text, Excel may keep it as a number. Always format first, then type. Similarly, copying numbers from another program and pasting them into Excel will paste them as numbers, not text, so the leading zeros will disappear. Paste into a Text-formatted cell to preserve them.
Another mistake is using the wrong number of zeros in the TEXT formula. If you use =TEXT(A1,"000") but your numbers are four digits, the result will be cut off. Count how many digits you need in the final result and use that many zeros in the pattern. For a five-digit zip code, use five zeros: =TEXT(A1,"00000").
Frequently Asked Questions
Will leading zeros affect sorting in Excel?
If the cells are formatted as Text, Excel sorts them alphabetically, not numerically. This means 00002 comes before 00010, which is usually what you want. If the cells are numbers, Excel will sort by value and ignore leading zeros. For most uses like zip codes or IDs, Text formatting is the right choice.
Can I add leading zeros to a whole column at once?
Yes. Select the entire column by clicking the column letter, then right-click and choose Format Cells. Select Text and click OK. Now any number you type in that column will keep its leading zero. If you already have numbers in the column, use the TEXT formula in a new column instead, then copy and paste values back.
What if I need different numbers of leading zeros in different rows?
Use the TEXT function with a pattern that matches your longest entry. For example, if some codes are three digits and others are five, use =TEXT(A1,"00000") to pad everything to five digits. All shorter codes will get leading zeros added automatically.
Does formatting as Text slow down Excel?
No. Text formatting has no meaningful impact on Excel's speed, even with thousands of entries. The only downside is that you cannot use Text-formatted cells in math formulas without converting them first.
How do I remove leading zeros if I change my mind?
Select the cells, right-click, choose Format Cells, and change the format back to Number. Excel will convert them to regular numbers and drop the leading zeros. If you want to keep the zeros, leave them as Text.