How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (2024)

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (1) Key Takeaways

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (2) If you want to add leading zeros to a single cell, adding an apostrophe at the beginning is the simplest solution. [More…]

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (3) If you want to add leading zeros to multiple cells, rows, or columns, the best solution is to select the cells, right-click them, and select “Format cells.” Then, go to “Custom,” enter a zero for each digit under “Type” (if the maximum length of your number is five digits, enter five zeros), and click “OK.” [More…]

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (4)

When you import documents into Excel for analysis, the numbers may appear differently than expected. That’s because Excel formats numbers to condense them, which is a problem for product codes or credit card numbers that often contain leading zeros. So, in this guide, we will look at how you can prevent Excel from removing leading zeros.

How to prevent Excel automatically removing leading zeros:

  1. In Excel, select the cells, rows, or columns that need leading zeros.
  2. Right-click the selected cells and choose “Format cells.”
  3. Go to “Custom” on the left menu.
  4. Under “Type,” enter the same number of zeros as there are digits in your number.
  5. Then click “OK.”
  • Get Excel for just $6.99 per month from the Microsoft Store!

If the number you want to store in Excel is five digits long, type “00000” without quotation marks in the “Type” field. Then, your custom format will replace thedefaultformat in the cells you selected. And when you enter “00123” into your formatted cells, the whole number will appear instead of “123.”

Please continue reading if the solution above does not solve your problem or if you need a detailed walkthrough of the steps provided.

We’ve also created a video to help guide you through the process:

Overview: What are leading zeros, and why does Excel remove them automatically?

Leading zeros are any zeros that come before a number greater than zero in a series of digits. For example, James Bond’s famous 007 identification has two leading zeros. However, if you enter “007” into a cell in your Excel worksheet, the default number format will remove the leading zeros.

Excel removes leading zeros because they do not affect the value of the number and are therefore seen as unnecessary. But some account or bank numbers require leading zeros, so you must create a custom format to retain them.

How to prevent Excel automatically removing leading zeros

In this guide, we will look at several solutions to prevent Excel from removing leading zeros. You can jump to the most relevant solution by clicking the links below or trying all solutions to find the best fix.

  • Solution 1: Use a custom number format.
  • Solution 2: Use a text format.
  • Solution 3: Use a formula.
  • Solution 4: Use an apostrophe.
  • Solution 5: Use third-party tools.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (6) Solution 1: Use a custom number format to prevent Excel automatically removing leading zeros

This solution is an expansion of the steps provided at the top of this guide. The solution will work on the desktop and web versions of Microsoft Excel.

In this demonstration, we have created a simple spreadsheet with an “Account Number” column that contains a ten-digit number with two leading zeros removed.

  • Open your How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (7) Excel worksheet.
  • Select the cells, rows, or columns that need leading zeros. (1)
    • In this demonstration, we clicked column header, “D.”
  • Right-click the selected cells. (2)
  • Then choose How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (8)Format cells” from the popup menu. (3)
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (9)
  • The Format Cells dialog box will open.
  • Ensure you are in the “Number” tab at the top of the dialog box. (1)
  • Go to “Custom” on the left menu. (2)
  • Under “Type,” enter the number of zeros in your number. (3)
    • The “Account Number” in this demonstration contains ten digits.
    • To retain leading zeros, we entered ten zeros in the “Type” field.
  • Then click the “OK” button. (4)
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (10)

The result shows that all the account numbers now have leading zeros, and each number is ten digits in length. Also, because we formatted the whole column, all additional account numbers will retain their leading zeros.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (11)

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (12) Solution 2: Use a text format to prevent Excel automatically removing leading zeros

This solution will not add leading zeros to existing numbers. Instead, it will format the cells so that any numbers added will be treated as text and retain their leading zeros.

  • Open your How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (13) Excel worksheet.
  • Select the cells, rows, or columns that need leading zeros. (1)
    • In this demonstration, we clicked column “D.”
  • Right-click the selected cells. (2)
  • Then choose How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (14)Format cells” from the popup menu. (3)
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (15)
  • The “Format Cells” dialog box will open.
  • Ensure you are in the “Number” tab at the top of the dialog box. (1)
  • Go to “Text” on the left menu. (2)
  • Then click the “OK” button. (3)
  • Alternatively, click the select box in the “Number” section in the ribbon.
    • The default format is “General.”
  • Then select “Text” at the bottom of the dropdown list.
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (16)

The result shows that the existing numbers have not been affected. However, all additional numbers added to the “Account Numbers” column will retain their leading zeros.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (17)

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (18) Solution 3: Use a formula to prevent Excel automatically removing leading zeros

This solution will use a formula in two ways. First, we will show you how to format the number similar toSolution 1using the Excel TEXT function. And second, we will show you how to add zeros to the beginning of your number.

Method 1: Use a TEXT formula to format the number

We have created an additional column adjacent to the “Account Number” column. This new column will contain a formula that will correctly format the account number.

  • Open your How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (19) Excel worksheet.
  • Double-click an empty cell, preferably next to your existing number. (1)
  • Paste the following formula into the cell:
=TEXT(CELL,"0000000000")
  • Change “CELL” to the cell address of your first number.
    • The cell address of our first account number is “D2.”
  • Change the number of zeros in the quotation marks to match the maximum length of your number.
    • Our account numbers are ten digits long, so there are ten zeros in the quotation marks.
  • Then press the Return key.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (20)

Method 2: Use a formula to add zeros

  • Open your How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (21) Excel worksheet.
  • Double-click an empty cell, preferably next to your existing number. (1)
  • Paste the following formula into the cell:
="00"&CELL
  • Change the number of zeros in the quotation marks as required.
    • Whatever is written in the quotation marks will appear at the beginning of the cell.
  • Change “CELL” to the cell address of your first number.
    • The cell address of our first account number is “D2.”
  • Then press the Return key.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (22)

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (23) Solution 4: Use an apostrophe to prevent Excel automatically removing leading zeros

If you insert an apostrophe before a number, Microsoft Excel will ignore the cell formatting and show the number as input. This approach ensures that even if the cell formatting is changed, the cell content will retain its original appearance.

If you want to add an apostrophe to all existing numbers, you can do that by building a macro in Visual Basic (VBA). Assuming that your numbers are missing their leading zeros, you will need to add an apostrophe and the leading zeros.

  • Open your How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (24) Excel worksheet and go to the “View” tab in the top menu. (1)
  • Click on the down-arrow under “Macros.” (2)
  • Select “Record Macro” from the dropdown menu. (3)
  • The “Record Macro” dialog box will pop up.
  • Enter a “Macro name.” (4)
  • Add an optional shortcut key. (5)
  • Then press the “OK” button. (6)
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (25)
  • Now go back to “Macros” in the menu and select How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (26)Stop recording.”
  • Return to “Macros” again and select How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (27)View Macros.”
  • Then click the “Step Into” button in the popup box.
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (28)
  • The VBA editor will now open, allowing you to build the macro.
  • Paste the following code just above “End Sub” in the editor:
Dim cell As RangeFor Each cell In SelectionIf cell.Value <> "" Then cell.Value = "'00" & cell.ValueNext
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (29)
  • The complete code should look similar to the following:
Sub Apostrophe()'' Apostrophe Macro'' Keyboard Shortcut: Ctrl+a'Dim cell As RangeFor Each cell In SelectionIf cell.Value <> "" Then cell.Value = "'00" & cell.ValueNextEnd Sub
  • Now return to your spreadsheet and select the cells to add leading zeros.
  • Then press the Ctrl + a keys (or your chosen shortcut) to run the macro.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (30)

The apostrophes will be ignored, allowing you to utilize the MATCH and VLOOKUP tools.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (31) Solution 5: Use third-party tools (Ablebits or Kutools) to prevent Excel automatically removing leading zeros

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (32) Ablebits Ultimate Suite

Ablebits will expand your Excel capabilities with over 70 professional tools and 300+ options. You can download and use Ablebits with a 14-day free trial, which grants you access to all the features required to add or remove leading zeros.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (33)

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (34) 70 professional tools and over 300 options
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (35) Select cells by value or color
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (36) Convert numbers to words
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (37) Split names into multiple columns

$99 One-time purchase – 14-day free trial

  • Close your Excel application and How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (38)download Ablebits.
  • Once installed, reopen your worksheet.
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (39)
  • You should notice two new tabs at the top of Excel:
    • Ablebits Data
    • Ablebits Tools
  • First, select the cells, columns, or rows you want to add leading zeros to. (1)
  • Then go to “Ablebits Tools.” (2)
  • Click “Utilities” on the right side of the top menu. (3)
  • Then click “Add/Remove Leading Zeros.” (4)
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (40)
  • A dialog box will open.
  • Select your range. (1)
    • If you’ve selected the cells to add zeros to, they will appear in the range box.
    • Otherwise, select your range in the worksheet without closing the dialog box.
  • Check the back up checkbox, as changes using this method cannot be undone with Ctrl + Z.
  • In our example, we want account numbers with ten digits. (2)
  • Click the “Apply” button to make the changes. (3)
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (41)

The result transforms the numbers into text and prepends zeros to the beginning of the cell. If you want to undo this action, you can close and reopen your workbook without saving.

Alternatively, you can return to “Utilities>Add/Remove Leading Zeros” and change the digits to a length that is equal to the current length minus the number of leading zeros.

In our example, we have ten digits with two leading zeros. To return the column to its previous state, we can set the number of characters to 8 instead of 10. Then, when we click “Apply,” the leading zeros will be removed. However, the column will remain formatted as text.

To change the data back to numeric values, select the cells and click the How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (42) warning icon. Then, select “Convert to Number” from the dropdown list.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (43) Kutools for Excel

Like Ablebits, Kutools has over 300 advanced tools and functions, including the option to add or remove leading zeros. You can also create searchable dropdown lists that will condense your data footprint.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (44)

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (45) More than 300 additional tools and options
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (46) Encrypt your workbooks
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (47) Create mailing lists
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (48) Use background and font color to sum cells.

$49 One-time purchase – 30-day free trial

  • First, close your Excel application and How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (49)download Kutools.
  • Once installed, reopen your worksheet.
  • You will see two new tabs at the top of Excel:
    • Kutools ™
    • Kutools Plus
  • Select the cells, rows, or columns to add leading zeros to. (1)
  • Go to the “Home” tab at the top. (2)
  • Click the select box in the “Number” section. (3)
  • Set the data type to “Text” from the dropdown menu. (4)
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (50)
  • If necessary, reselect the cells, rows, or columns to add leading zeros to. (1)
  • Go to “Kutools ™” at the top. (2)
  • Click “Text” in the “Editing” section. (3)
  • Then select “Add Text” from the dropdown menu. (4)
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (51)
  • Enter the number of zeros you want to add in the “Text” box.
  • Select “Before first character” as the “Position.”
  • Then click the “OK” button.
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (52)

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (53) Frequently Asked Questions (FAQ)

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (54) How do you format a cell to keep leading zeros?

The simplest way to format a single cell so that it keeps leading zeros is to add an apostrophe at the beginning of the cell.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (55) How do you keep leading and trailing zeros in Excel?

We’ve discussed how to keep leading zeros in this guide. However, if you want to keep trailing zeros (those which appear after decimals), you can do that by following these simple steps:

  • Select the cells, rows, or columns to add trailing zeros to. (1)
  • Right-click the selected cells. (2)
  • Then choose How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (56)Format cells” from the popup menu. (3)
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (57)
  • The “Format Cells” dialog box will open.
  • Ensure you are in the “Number” tab at the top of the dialog box. (1)
  • Go to “Custom” on the left menu. (2)
  • Under “Type,” enter “0.00” to add two trailing zeros. (3)
  • Then click the “OK” button. (4)
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (58)
How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (59)

Conclusion

If you want to keep leading zeros in a single cell, the simplest solution is to add an apostrophe to the beginning of the cell. If you want to add leading zeros to multiple cells, rows, or columns, you can format the cells using Solutions 2 or 3.

As there are native solutions for adding leading zeros, we do not advise purchasing third-party software for that sole purpose. However, given the array of tools on offer in Ablebits and Kutools, it’s certainly worth looking at if you’re a regular Excel user.

Thanks for reading.

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet (2024)

FAQs

How to actually prevent Excel automatically removing leading zeros | Business Tech Planet? ›

To do this, select the cells, right-click, choose "Format Cells," and then select "Text" from the Category list. This should prevent Excel from removing leading zeros. Verify Data Entry: Double-check how the data is entered into Excel.

How do I stop Excel from removing leading zeros by default? ›

To do this, select the cells, right-click, choose "Format Cells," and then select "Text" from the Category list. This should prevent Excel from removing leading zeros. Verify Data Entry: Double-check how the data is entered into Excel.

How do I automatically remove leading zeros in Excel? ›

Remove leading zeros by changing the cell format

If leading zeroes are shown in cells with a custom format, then change the cell format back to default General, or apply another number format that does not display preceding zeros.

How do I turn off zero suppression in Excel? ›

Click the File tab, choose Options in the left pane and then click Advanced in the left pane. 2. In the Display options for this worksheet section, uncheck Show a zero in cells that have zero value (Figure A). Uncheck this option to suppress zero values.

How to keep leading zeros in Excel when combining cells? ›

Imagine you have a number in cell A1 and text in cell B1. To concatenate them with leading zeros, use the following formula in a new cell: Concatenate(TEXT(A1, "00000"), B1). This will output the number from A1 with leading zeros followed by the text from B1 in one cell.

How do I stop sheets from removing leading zeros? ›

The key to keeping leading zeros in Google Sheets is to format the cells that contain the data as text. This can be done by selecting the cells, right-clicking, and choosing "Format Cells." In the Format Cells dialog box, choose "Text" from the Number tab and then click "OK."

How do I keep leading zeros Text to columns in Excel? ›

In Options, under "Data" and "Automatic data conversion", the default for "Remove leading zeros and convert to a number" was enabled. Unchecking that option worked.

How to keep leading zeros in dates in Excel? ›

Include leading zeros in date go to Format Cells Tab and click Date. Then search for the correct date format with preceding zeros. After following the steps outlined above you'll be able to add leading zeros in your date. Related Article: How To Remove Excel Add-in?

How do I get rid of leading and trailing zeros in Excel? ›

Type a “0” (zero) into the “Decimal Places” box. Click OK. It's at the bottom-right corner of the screen. This brings you back to your spreadsheet, where you should no longer see zeros before your numbers.

How do I make Excel not ignore zeros? ›

Go to File > Options > Advanced. Under Display options for this worksheet, select a worksheet, and then do one of the following: To display zero (0) values in cells, check the Show a zero in cells that have zero value check box.

How do you prevent Excel from removing leading zeros? ›

To do this, you can do one of two things:
  1. Format the column as Text. Select your data range and press Ctrl+1 to launch the Format > Cells dialog. On the Number tab, click Text. ...
  2. Use the apostrophe character. You can type an apostrophe (') in front of the number, and Excel will treat it as text.

How do you paste into Excel without losing leading zeros? ›

To prevent this, you can first apply the Text format to the cells before you type or paste the numbers. Here's how: Select the cells on your worksheet where you'll be adding the data. Right-click anywhere in the highlighted cells, and then on the shortcut menu, click Number Format >Text >OK.

How do I stop Excel from plotting zero values? ›

Charting a filtered dataset
  1. Click inside the data range.
  2. On the Data tab, click Filter in the Sort & Filter group. ...
  3. Click Vendor 1's drop-down and uncheck zero (Figure L). ...
  4. Click OK to filter the column, which will filter the entire row.
Oct 6, 2023

How do I stop Excel from changing cell format automatically? ›

If you want to review and change automatic formatting options all at once, you can do that in the AutoCorrect dialog box.
  1. Click File > Options.
  2. In the Excel Options box, click Proofing > AutoCorrect Options.
  3. On the AutoFormat As You Type tab, check the boxes for the auto formatting you want to use.

How do I stop Excel from changing numbers? ›

To prevent auto-formatting, just do the following:
  1. Select the range where you'll have your special data. It can be a column or a number of columns. ...
  2. Right-click on the range and select "Format Cells…", or press Ctrl+1.
  3. Select Text in the Category list on the "Number" tab.
  4. Click Ok.
Oct 10, 2023

Top Articles
Latest Posts
Article information

Author: Sen. Ignacio Ratke

Last Updated:

Views: 6014

Rating: 4.6 / 5 (56 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Sen. Ignacio Ratke

Birthday: 1999-05-27

Address: Apt. 171 8116 Bailey Via, Roberthaven, GA 58289

Phone: +2585395768220

Job: Lead Liaison

Hobby: Lockpicking, LARPing, Lego building, Lapidary, Macrame, Book restoration, Bodybuilding

Introduction: My name is Sen. Ignacio Ratke, I am a adventurous, zealous, outstanding, agreeable, precious, excited, gifted person who loves writing and wants to share my knowledge and understanding with you.