

The number of zeros in the format code corresponds to the total number of digits you want to show in a cell (you will find a few examples below).įor example, to add leading zeros to create a 5-digit number, use the following format code: 00000īy using Excel custom numbers formats, you can add leading zeros to create fixed-length numbers, like in the above example, and variable-length numbers. In most cases, you will need a format code consisting of 0 placeholders, like 00.
EDITRA DELETING AS YOU TYPE HOW TO
How to show leading zeroes in Excel using a custom number format

If that is not what you want, then change only the visual representation of the value by applying a custom number format as demonstrated in the next example. In this case, you don't need to change the cell's format.īottom line: This simple technique has a significant limitation - the resulting value is a text string, not number, and consequently it cannot be used in calculations and numeric formulas. For example, instead of typing 01, type '01. The following screenshot shows the result:Īnother way to keep leading zeros in Excel is to prefix a number with an apostrophe ('). To remove that error indicator, select the cell(s), click the warning sign, and then click Ignore Error. Go to the Home tab > Number group, and select Text in the Number Format box.Īs soon as you type a zero(s) before number, Excel will display a small green triangle in the top-left corner of the cell indicating that something is wrong with the cell contents.Select the cell(s) where you want to prefix numbers with 0.For this, simply change the cell format to Text: How to keep leading zeros in Excel as you typeįor starters, let's see how you can put 0 in front of a number in Excel, for example type 01 in a cell. Add and remove zeros in Excel an easy way.Add leading zeros to numbers (TEXT function).Show leading zeros using a custom format.Keep leading zeros in Excel as you type.Luckily, Excel also provides the means to keep leading zeros in cells, and further on in this tutorial you will find a handful of ways to do it. The point is that Microsoft Excel treats postal codes, phone numbers and other similar entries as numbers, applies the General or Number format to them, and automatically removes preceding zeroes.
EDITRA DELETING AS YOU TYPE ZIP
However if you try typing a zip code like "00123" in a cell, Excel will immediately truncate it to "123".

If you use Excel not only to calculate numbers, but also maintain records such as zip codes, security numbers or employee ids, you may need to keep leading zeros in cells. This tutorial shows different ways to add leading zeros in Excel: how to keep zeros as you type, show leading zeros in cells, remove or hide zeros.
