How to keep leading zeros in excel
Tutor 5 (120 Reviews)
Excel Tutor
Still stuck with a Excel question
Ask this expertAnswer
To keep leading zeros in Excel, you must format cells as text before entering the data or use a formula approach. Excel automatically removes leading zeros from numbers, so these methods prevent that default behavior.
Method 1: Format Cells as Text Before Entry
Step-by-step instructions:
- Select the cell or range where you want to enter data with leading zeros
- Right-click and choose "Format Cells" (Windows: Ctrl+1, Mac: Cmd+1)
- Navigate to the "Number" tab
- Select "Text" from the Category list
- Click "OK"
- Enter your data with leading zeros
- Press Enter
The cell now displays leading zeros exactly as you type them. This method works for phone numbers (0123456789), product codes (00547), identification numbers (007), and ZIP codes (01234).
Method 2: Use an Apostrophe Before the Number
Step-by-step instructions:
- Click on the cell where you want to enter data
- Type an apostrophe (') before your number (example: '00123)
- Press Enter
The apostrophe tells Excel to treat the entry as text, preserving all leading zeros. The apostrophe itself does not display in the cell. You can use this method for individual entries without pre-formatting cells.
Method 3: Use a Formula with TEXT Function
Step-by-step instructions:
- Click on the cell where you want the result
- Enter a formula using the TEXT function
- Type: =TEXT(A1,"00000") where A1 contains your number and each 0 represents a digit position
- Press Enter
This method converts numbers to text with specified leading zeros. For a 5-digit code with leading zeros, use five zeros in the format. For a 9-digit number, use nine zeros.
Method 4: Use CONCATENATE or & Operator
Step-by-step instructions:
- Click on the cell for your result
- Enter: ="0"&A1 (to add one leading zero) or ="00"&A1 (for two leading zeros)
- Press Enter
This formula combines text zeros with your number value. Adjust the number of quoted zeros based on how many leading zeros you need.
Important Considerations
Cells formatted as text do not participate in mathematical calculations. Formulas referencing text-formatted numbers may not calculate correctly. Store leading zero data in text format when sorting, searching, or matching is required, since text entries sort differently than numbers (007 sorts before 70, for example).
The apostrophe method and text formatting are permanent solutions that persist when saving and reopening files. CSV imports often lose leading zeros—reapply text formatting after importing CSV data to retain them.
Windows and Mac versions function identically for these methods. The keyboard shortcuts differ (Ctrl+1 on Windows versus Cmd+1 on Mac), but the menu navigation remains the same.
. Was this Helpful?Get Online Tutoring or Questions answered by Experts.
You can post a question for a tutor or set up a tutoring session
Answers · 1
How to track changes in excel
Answers · 1
How to lock certain cells in excel
Answers · 1
How to merge two excel spreadsheets
Answers · 1
Where is the name box in excel
Answers · 1