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

Transposing Letters

My fat fingers sometimes result in typing letters in the wrong order. Here's a quick tool that allows you to easily ...

Discover More

Distributing Table Rows Evenly

If you've adjusted the height of your table and the rows within the table, you might want to later return all those rows ...

Discover More

Fitting to a Single Page

It can be frustrating when a single-page document actually prints of two pages, depending on the system that is doing the ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Understanding Underlines

Excel provides a variety of underlining styles you can use when you need to underline information within a cell. Here's ...

Discover More

Saving a Custom Table Style

When you format your data as a table, Excel allows you to apply a style to that table. You can even create your own table ...

Discover More

Deleting Unwanted Styles

Custom styles can be a great help in formatting a worksheet. You may, at some point, want to get rid of all the custom ...

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

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.