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

Defeating Automatic Date Parsing

by Allen Wyatt
(last updated March 23, 2015)

5

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/09).

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 Excel 2013 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, and 2013. 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

Preventing Styles from Changing

It is frustrating to spend a lot of time working on a document, getting your styles just right, and then have those ...

Discover More

Meaningless Text

Need to quickly put some text into a document, even if that text is essentially meaningless? Here's how to put this type ...

Discover More

Adding a Comment to Multiple Cells

Adding a comment to a single cell is easy. What if you want to add the same comment to multiple cells, however? Here are ...

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)

Setting Vertical Alignment

Excel allows you to adjust not only the horizontal alignment of values in a cell, but also the vertical alignment. This ...

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

2015-02-09 15:36:59

Gerald Britton

My situation is similar, however in my case I open csv files (output from an automated database job) in Excel. Before I get a chance to do anything to the data, Excel has parsed it as dates.


2014-09-29 13:34:03

becka

I have a workbook that I send to coworkers to initiate a legal process where they have to complete about 20 fields on the first page, 3 of which are dates or date ranges, and all cells copy to other areas of the workbook. Even though both the cell where the date is typed, and the cell to which the date is copied are formatted as dates, when I copy the copied dates into yet another database (using copy values), they often end up as not-dates. Is this related?


2014-09-28 08:51:07

JEN NGU

Believe if you perform a text to column & thereafter format accordingly to your needs, it works.


2014-09-27 06:01:09

Mike Davies

or just put ' at the beginning (or " to right-align)


2014-09-27 05:13:53

Richard Wakefield

Wouldn't it be easier to format the cells that will contain the information to be imported as "Text"? That way Excel won't do any date conversion.


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.