Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Pasting Leading Zeroes.

Pasting Leading Zeroes

Written by Allen Wyatt (last updated April 26, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


2

Some data requires leading zeroes. The first example that comes to mind is ZIP Codes, in which some have leading zeroes. There are other examples, as well. For instance, you may have a chart of accounts in which general ledger account numbers start with leading zeroes.

When you paste information into Excel, it normally tries to "parse" the data and put it in a format that it can work with. When you paste data that have leading zeroes, and the data could reasonably be construed as numbers, then Excel strips the leading zeroes from what you are pasting. For instance, 0012387 becomes a number value, 12387.

What if you want to retain the leading zeroes? The answer depends on whether you are copying and pasting from a non-Excel source or from data already in an Excel workbook.

Non-Excel Sources

If you are copying information from a non-Excel source, such as a text file or even from a website, including the leading zeroes is pretty straightforward. The key (and the part that many people miss) is to make sure that the target cells—the ones that will receive the data being pasted—are formatted as text before you do the pasting. Follow these steps:

  1. Select the cells that will hold the data you are going to paste.
  2. Display the Home tab of the ribbon.
  3. Click the small icon at the lower-right corner of the Number group. Excel displays the Format Cells dialog box, with the Number tab selected. (See Figure 1.)
  4. Figure 1. The Number tab of the Format Cells dialog box.

  5. In the Category list, choose Text.
  6. Click on OK.

You should now be able to paste with absolutely no problem. Formatting the cells as text means that Excel won't try to parse numbers as numbers, instead it will allow them to be pasted into the cells "as they are."

Excel Sources

If your data is in an Excel workbook, how you paste can seem a bit confusing at times. The key is to remember that there are two distinct parts to anything you copy and paste—content and formatting of that content.

As an example, let's say that the data you want to copy already has leading zeroes—you can see them on the screen! Sounds great, right? Well, you should select a cell that shows leading zeroes and then look at what you see in the Formula bar. If what you see there does not show the leading zeroes, then the value in the cell is a numeric value formatted to display those leading zeroes, probably using a custom format. If the Formula bar includes the leading zeroes, then the cell is more than likely formatted as text. In either case, you can copy and paste the cell and the formatting should travel with what you copy—meaning that what you paste will include the leading zeroes or at least appear to have leading zeroes.

If you don't want to copy the cell formatting, then you'll need to use Paste Special (click the down-arrow at the right of the Paste tool on the Home tab of the ribbon) to paste just the values. If you paste values into cells previously formatted as text (see earlier in this tip), then the numeric values are thereafter treated as text values. They won't, however, include any leading zeroes because the original numeric values didn't really have any leading zeroes.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12477) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Pasting Leading Zeroes.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Getting Rid of "Copy of"

When you save a read-only workbook file under a new name, Excel automatically adds "copy of" to the beginning of that ...

Discover More

Playing with a Full Deck

Ever need to populate some cells in your worksheet with a range of data, but in random order? Here's a handy macro to get ...

Discover More

Controlling Widows and Orphans

Got singular lines at the bottom or top of a page? These are often referred to as widows and orphans, and Word allows you ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Swapping Two Cells

If you need to swap the contents of two cells in your worksheet, Excel provides a number of ways you can approach the ...

Discover More

Pasting Excel Data within Word's Page Margins

The programs in the Microsoft Office suite are designed to work with each other easily. Sometimes there can be hiccups ...

Discover More

Undoing an Edit

We all make mistakes. Fortunately, Excel makes it rather easy to undo your makes, right after you make them.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 7?

2023-04-27 08:59:17

Tomek

@Les,
Your suggestion can be used only when entering the data, but not when pasting.


2023-04-26 05:31:33

Les

A simple procedure in order to display leading zeroes is to insert an apostrophe (') at the head of the characters. This forces text format - and the leading apostrophe is not displayed.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.