Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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

by Allen Wyatt
(last updated September 27, 2016)

12

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 become a number value, 12387.

What if you want to retain the leading zeroes? All you need to do is make sure that the target cells—the ones that will receive the data being pasted—are formatted as text. 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.

Whatever you now paste into the formatted cells is assumed to be text, and Excel will leave your leading zeroes exactly as you expect them.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12477) applies to Microsoft Excel 2007, 2010, and 2013. 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

Fixing Word

Need to make sure that Word is installed correctly from the original installation CDs? You can do it by using a command built ...

Discover More

Excel 2007 PivotTables for the Faint of Heart (Table of Contents)

PivotTables are a powerful tool for consolidating huge amounts of data. PivotTables 2007 for the Faint of Heart shows ...

Discover More

Self-Deleting Macros

Macros are very powerful, but you may not want them to always be available to a user. Here are some ways you can limit their ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Splitting Information into Rows

Got too much information in a single cell? Here's how you can use a macro to pull apart that information and put it into ...

Discover More

Moving and Copying Cells

At the very heart of editing is the ability to move and copy cells in a worksheet. Understanding the differences between ...

Discover More

Getting Rid of Everything Except Numbers

Got some numbers and letters mixed up in the same cell? You may need to get rid of those letters so you are left with just ...

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}] 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 7 + 6?

2016-09-28 05:27:00

John

Hi,

you could also format the cells(or columns)from the custom tab.

This would allow them to be stored as numbers and also act as data verification.


2016-09-27 19:02:10

Dermot McNamara

Isn't the problem people have been having coipying from another programme that the source formating is over writing the formating of the destination cell.
Using paste special and selecting text will keep the leading zeros in a cell formated for text.


2016-09-27 16:16:14

Thomas Papavasiliou

If you copy the data from another area, sheet or book, you may use the paste special command and paste the formats as well.


2016-09-27 14:31:07

Gary Harlow

Rather than formatting to text, use "custom" formatting with "0#####.00" with or without a decimal, in order that the value can be calculated, sorted, and/or otherwise utilized. As a text value, it would require additional functions, such Value, to be sorted sequentially, or otherwise.


2016-09-27 11:52:53

Luis

Funny enough, I notice this tip was written in 2013. Has Excel changed it behaviour since then?


2016-09-27 11:50:59

Luis Panozzo

Unfortunately I have to concur with the "not working" situation (Excel for Mac Version 15).
If i define the cell as text and enter 0098 ... I get 0098 (left justified).
But if I copy 0098 from Word and paste it in the cell, I get 98 (right justified)
Moreover, the pull down menu in the ribbon changes from Text to General.


2016-09-27 11:08:27

Don Meyerson Sr

Another way is to enter the characters with a leading apostrophe. Then the entry is automatically formatted as text.


2016-09-27 10:59:20

Peg Molter

I tried this and it didn't work. I intentionally formatted the Excel cells as text before copying cells from a Word table that contained leading 0s. As soon as I pasted them into Excel, Excel interpreted them as numbers, reformatted the cells accordingly, and again, omitted the leading zeros. Of course it works in Excel if the numbers you copy are already in Excel and contain an apostrophe, because that gets copied along with the contents. But I don't think that was the intent of this tip.


2016-09-27 09:41:06

Mel

Unfortunately this doesn't seem to work for me. I have a sheet that is updated by multiple users and they copy out of 1 program and paste into the sheet. Even changing the cell to TEXT, when the data from the program is pasted into that cell, Excel changes the formatting to general and removes the leading zero. I would love other tips besides adding a leading ' because we have a lot of non excel users and it is a chore to clean up every week since they don't understand excel.


2016-09-27 07:30:37

AT

Another option would be to use the =text(A3,"00000") formula in the original document and then copy and paste as values in the receiving document.


2014-06-19 12:02:06

Ted Babcock

This is a great tip, and I've been using it for small sets of data. However, sometimes I'm pasting many columns, with mixed data types, and so I have to go through and mark just specific columns as Text. Isn't there a way to tell Excel a general rule? "If it looks like a number but has leading zeroes, treat it as text." Thanks!


2013-02-18 10:26:29

Glenn Case

You can also use a custom format to format your numbers with leading zeros; for instance, for zip codes, a format of 00000 will produce a 5-digit number perfaced with zero as needed.


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.