Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Preceding 0 in Excel

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can precede a zero in Excel, but you must change the cell format first because Excel automatically treats numbers starting with 0 as text. The most reliable way to do this is to format the cells as Text before entering the numbers, or use the apostrophe trick to force Excel to treat the entry as text. This ensures that the leading zero is saved and displayed exactly as you type it.

What You'll Need

  • A computer with Microsoft Excel installed (Excel for Microsoft 365, Excel 2019, Excel 2016, or Excel 2013).
  • A dataset containing numbers that require a leading zero, such as product codes, zip codes, or phone extensions.
  • A basic understanding of the Ribbon interface (the top menu bar in Excel).

Step-by-Step

  1. Identify the target cells. Click on the single cell or the range of cells where you want to start typing numbers with a leading zero. For this guide, imagine you have a list of product codes in column A that all start with 0, such as 01234, 00999, and 00001.
  2. Open the Format Cells dialog. With the cells selected, right-click anywhere inside the selection. In the context menu that appears, click on Format Cells.... Alternatively, you can press the keyboard shortcut Ctrl + 1 on your keyboard. This opens the main formatting dialog box.
  3. Choose the Text format. In the dialog box that appears, you will see several tabs at the top (General, Number, Currency, etc.). Click on the Number tab, and then look for the category list on the left side. Select Text from this list.
  4. Confirm the selection. Click the OK button at the bottom right of the dialog box. The selected cells will now be formatted as text. You will notice that the column header (e.g., the letter "A") in the spreadsheet tab strip may turn from a general green/blue icon to a green icon representing text.
  5. Enter the data with the leading zero. Now, simply type the number directly into the first cell. For example, type "01234" and press Enter. Because the cell is formatted as text, Excel will not remove the first zero. It will display "01234" exactly as you typed it.
  6. Drag to fill the rest of the column. If you have a long list of similar codes, type the first one, then click and drag the small square fill handle (the small green square at the bottom-right corner of the selected cell) down to fill the rest of the column. Excel will automatically copy the text format and the value, preserving the leading zero for every cell.
  7. Alternative: The Apostrophe Trick. If you have already typed numbers into cells and realized they lost their zeros, you can fix them quickly without changing the whole column format. Click into the first cell that needs fixing. Type a single apostrophe (') at the very beginning of the existing text (so it looks like \'01234). Then press Enter. Excel will treat this as a text entry. You can then delete the apostrophe from the beginning of the cell and press Enter again. The cell will now retain the leading zero, and you can copy and paste this cell to the others.
  8. Alternative: Using the CONCATENATE function. For more complex scenarios where you might be combining data, you can use the CONCATENATE (or TEXT in newer Excel versions) function to build the string. For example, if you have a number 1234 in cell B2 and you want to precede it with 0, you would type =CONCATENATE("0", B2) or =TEXT(B2, "0000"). The TEXT function is particularly powerful because it allows you to pad a number with zeros to a specific length (e.g., "0000" ensures that 123 becomes 0123).

Common Mistakes

One of the most common errors users make is typing the number, hitting Enter, and then realizing the leading zero has vanished. This happens because Excel defaults to the General number format. It interprets "01234" as the number twelve thousand three hundred and thirty-four, so it removes the leading zero to present a cleaner number. Another mistake is using the apostrophe trick on a cell that is already formatted as text; while it won't break the sheet, it adds unnecessary clutter to the formula bar.

Tips

When working with zip codes or phone numbers that start with zero, formatting the entire column as text upfront is usually the cleanest method. If you need to perform mathematical operations on the numbers later, you must convert them back to numbers using the Data > Text to Columns command or the VALUE function. Be aware that if you paste data from another source into these cells, the formatting might revert to General, so it is good practice to double-check the column format after pasting.

Troubleshooting

If you have followed the steps and the leading zero is still not appearing, check the cell alignment. Text entries in Excel are typically aligned to the left by default, whereas numbers are aligned to the right. If your cell is aligned to the right, it is still formatted as a number, and the zero will be stripped away upon entry. Ensure you have selected the entire range of cells before applying the Text format, as formatting just one cell will not change the behavior of the others.

Frequently Asked Questions

Why does Excel keep deleting the zero I type?

Excel deletes the leading zero because it interprets the number as a value, not text. By default, Excel treats a number starting with zero as a decimal or a long integer, and it removes the unnecessary leading zero to keep the data clean.

Can I use the TEXT function to add zeros?

Yes, the TEXT function is very effective for this. For example, using =TEXT(A1, "0000") will convert the number in A1 into a four-digit text string, padding it with zeros if necessary.

Does the apostrophe method work for all versions of Excel?

Yes, the apostrophe method is a universal Excel trick that works in every version of Excel for Windows, Mac, and Excel on the web.

How do I convert text with leading zeros back into a number?

You can use the VALUE function. For instance, =VALUE(A1) will convert the text "01234" back into the number 1234, provided the cell contains only text and no other characters.

Is there a shortcut to apply Text format?

Yes, you can select the cells and press Ctrl + 1 to open the Format Cells dialog, then select Text. Alternatively, you can go to the Home tab on the Ribbon, click on the small arrow in the Number group, and select Text from the list.