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

Including Section Numbers in an Index

When you use Word to create your index, you'll normally only include a page number in the index. If you want to create an ...

Discover More

ExcelTips Ribbon 2021 Archive (Table of Contents)

ExcelTips is a weekly newsletter that provides tips on how to best use Microsoft's spreadsheet program. At the ...

Discover More

Merge and Center Not Available

What are you to do if you are trying to format a worksheet, only to find out that one of the tools you need is not ...

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)

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

Preventing Changes to Formatting and Page Size

When you create workbooks for others to use, you might want to make sure that they can't change the formatting and paper ...

Discover More

Mimicking Small Caps in Excel

Word provides a much wider range of formatting tools and options than you can find in Excel. One example is when it comes ...

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 7 + 3?

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.