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: Defeating Automatic Date Parsing.

Defeating Automatic Date Parsing

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


2

Excel is normally pretty smart when it comes to importing data, but sometimes the automatic parsing it uses can be a real bother. For instance, you may import information that contains text strings, such as "1- 4- 9" (without the quotes). This is fine, but if you do a Replace to get rid of the spaces, Excel automatically converts the resulting string (1-4-9) to a date (1/4/2009).

One potential solution is to copy your information to Word and do your searching and replacing there. The problem with this solution is that when you paste the information back into Excel, it will again be parsed as date information and automatically converted to the requisite date serial numbers.

The only satisfactory solution is to make sure that Excel absolutely treats the resulting strings as just that—strings—and not as dates. This can be done in one of two ways: just make sure that the original text begins with either an apostrophe or a space. This can be ensured by using the Replace feature of Excel (depending on the data you have to work with) or by using the Replace feature of Word (which is much more versatile).

With an apostrophe or space at the beginning of the cell entry, you can remove additional spaces or characters from the cell contents. If the result is text that looks like a date, Excel will not parse it as such because the leading apostrophe or space forces treatment as text.

Another way to perform the task is to follow these steps. (Assume that the original data is in the range A2:A101).

  1. Insert a column to the right of the original data.
  2. In cell B2, enter the following formula:
  3.        =SUBSTITUTE(A2," ","")
    
  4. Copy the contents of B2 into the range B3:B101.
  5. Select the cells in the range of B2:B101.
  6. Press Ctrl+C to copy the range to the Clipboard.
  7. Select cell A2.
  8. Display the Home tab of the ribbon.
  9. Click the down-arrow under the Paste tool and then choose Paste Special. Excel displays the Paste Special dialog box. (See Figure 1.)
  10. Figure 1. The Paste Special dialog box.

  11. Make sure the Values option is selected.
  12. Click on OK.
  13. Delete column B.

If you are using Excel 2010 or a later version, you can use a shortcut for steps 8 through 10. When you click the down-arrow under the Paste tool (step 8), you see a small palette of options. Select the Values option in the Paste Values section of the drop-down list. The Values option is the left-most option in the Paste Values section; it looks like a clipboard with the number 123 on it.

These steps work because the output of the SUBSTITUTE function is always treated as text. When you copy and paste text values, they are treated as text with no additional parsing done by Excel.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9331) 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: Defeating Automatic Date Parsing.

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

Controlling Footnote Placement

Footnotes are normally placed at the bottom of the page on which the footnote is referenced. However, Word provides some ...

Discover More

Rounded Corners on Cells

As you are formatting a worksheet, Excel allows you to easily add borders to cells. Adding rounded corners to cells is a ...

Discover More

Filtering to a Date Range in the Past

If you have a large number of data records, each with an associated date, you might want to filter that data so you see ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Changing Currency Formatting for a Single Workbook

Currency is formatted differently in different corners of the world. Most formatting uses periods and commas to indicate ...

Discover More

Setting Cell Width and Height Using the Keyboard

Hate to take your hands off the keyboard? Here are a couple of ways you can reject the mouse and still adjust the height ...

Discover More

Getting Rid of Negative Zero Amounts

Have you ever seen a worksheet in which some zero values have a negative sign in front of them? There's a reason for ...

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 six more than 2?

2019-09-30 09:17:43

JMJ

@Peter McNab
Thank you for this useful remark and the very clear example!


2019-09-29 22:08:18

Peter McNab

There is a third and simpler way.
It seems that Excel will parse entered values to match an existing format applied to a cell.
So if you know in advance that you will be entering part numbers, for example, that have a format like a date, just format the cells as text before you enter. Then your entries will not parsed as dates.
It also seems that Excel does not even attempt parsing fractions unless the cell is already formatted 'Fraction'.
(see Figure 1 below)
In the first row of this table, I have manually converted the data to text with a quote mark. The Type column contains the Excel Type() function which returns 1 for number, 2 for text, 4 for logical etc.

Figure 1. The result of formatting before vs after entering data


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.