To show a 0 before a number in Excel, the fastest way is to type a single apostrophe (') before the number (e.g., '01234) or change the cell format to "Text." By default, Excel treats digits as mathematical values and automatically removes leading zeros because they do not change the value of the number. To keep them, you must tell Excel to treat the entry as text or apply a specific visual mask.
What You'll Need
- A computer with Microsoft Excel installed (works across Windows and macOS versions).
- The data you wish to format (such as ZIP codes, ID numbers, or phone numbers).
Step-by-Step
Depending on whether you are entering new data or fixing existing data, choose one of the following four methods. Note that menu labels may differ slightly depending on your version of Excel or region.
Method 1: The Apostrophe Trick (Best for quick, single entries)
- Click on the cell where you want to enter the number.
- Type a single quotation mark/apostrophe (') first.
- Type your number starting with zero (e.g., '0555).
- Press Enter.
The apostrophe will not be visible in the cell, but it tells Excel to treat the rest of the entry as text, preserving the zero.
Method 2: Formatting Cells as Text (Best for large lists of new data)
- Highlight the cells, columns, or rows you intend to fill with numbers.
- Go to the Home tab on the top ribbon.
- In the Number group, click the dropdown menu (which usually says "General").
- Scroll down and select Text from the list.
- Type your numbers with leading zeros; they will now remain exactly as entered.
Method 3: Custom Number Formatting (Best for consistent lengths, like IDs)
Use this method if you have numbers of varying lengths but want them all to be the same length (e.g., making "12" look like "0012").
- Select the cells containing the numbers.
- Right-click the selection and choose Format Cells... (or press Ctrl + 1 on Windows / Cmd + 1 on Mac).
- In the Number tab, select Custom from the Category list on the left.
- In the Type box, enter a series of zeros representing the total number of digits you want. For example, if you want all numbers to be 5 digits long, type
00000. - Click OK.
Excel will now automatically add leading zeros to any number that is shorter than the number of zeros you typed in the box.
Method 4: Using the TEXT Function (Best for combining data)
- Click in an empty cell next to your original number.
- Type the formula:
=TEXT(A1, "00000")(Replace A1 with your cell reference and "00000" with the desired number of digits). - Press Enter.
- Drag the fill handle (the small square at the bottom-right of the cell) down to apply the formula to other rows.
Common Mistakes
- Applying Text Format After Typing: If you type "0123" and it turns into "123," changing the format to "Text" afterward will not bring the zero back. You must format the cell as Text before typing the number, or re-type the number after changing the format.
- Using Custom Formatting for Variable Lengths: Custom formatting (e.g.,
00000) forces every number to that length. If you have some IDs that are 4 digits and some that are 6, this method will add too many zeros to the 4-digit ones and do nothing for the 6-digit ones. - Confusing Visuals with Data: Custom formatting only changes how the number looks. If you copy that cell and paste it into a plain text editor (like Notepad), the leading zeros may disappear because the underlying value is still just a number.
Tips
- Green Triangle Warning: When you use the apostrophe or Text format, Excel may show a small green triangle in the corner of the cell. This is just a warning that "a number is stored as text." You can ignore it, or select the cells, click the yellow warning icon, and select Ignore Error.
- Data Validation: If you are creating a form for others to fill out, pre-format the entire column as "Text" so users don't have to remember to use apostrophes.
- Quick Conversion: If you have a massive list of numbers and need to add a zero to all of them, the
=TEXTfunction is significantly faster than manual entry.
Troubleshooting
The zero still disappears after I press Enter.
Check the Number format dropdown in the Home tab. If it says "General" or "Number," the zero will be removed. Change it to "Text" and re-enter the value.
The Custom Format added too many zeros.
You likely entered too many zeros in the "Type" box. If you want a maximum of 5 digits, ensure you only have five zeros (00000) in the Custom Format settings.
My formulas aren't working with the "Text" numbers.
Some advanced mathematical formulas may struggle with cells formatted as text. If you need to perform calculations, use the Custom Number Formatting method (Method 3) instead, as it keeps the value as a number while only changing the visual display.
Frequently Asked Questions
Will leading zeros affect my calculations?
If you use the Text format or the apostrophe method, Excel treats the entry as a string of characters, not a number. While basic addition often still works, some complex formulas may return errors. Use Custom Formatting to keep the value as a number.
How do I remove leading zeros from a column?
The easiest way is to select the column, go to the Data tab, select Text to Columns, click Finish immediately. Excel will convert the text back to numbers and strip the zeros.
Does this work for ZIP codes?
Yes. Since many ZIP codes (especially in the Northeast US) start with zero, using the "Text" format or Custom Formatting (00000) is the standard way to handle them in Excel.
Can I add a zero to a number using a formula without changing the format?
Yes, you can use the concatenation symbol (&). For example, ="0"&A1 will put a zero in front of whatever is in cell A1. Note that the result will be treated as text.
Why does Excel do this in the first place?
Excel is designed for data analysis and accounting. In mathematics, 010 is the same as 10. To save memory and ensure mathematical accuracy, Excel removes "unnecessary" zeros unless specifically told that the zero is a character (like in a phone number) rather than a value.