+ Reply to Thread
Results 1 to 6 of 6

Excel changes formatting of certain strings.

  1. #1
    Registered User
    Join Date
    10-17-2016
    Location
    Saugatuck, MI
    MS-Off Ver
    Office 365 (2016)
    Posts
    3

    Excel changes formatting of certain strings.

    I am writing a workbook for Managing Haz Waste. In this book, I use Chemical Abstract Service Numbers which are in the form of any of the following formats: XXXXX-yy-z, XXXX-yy-z, XXX-yy-z, or XX-yy-z. I have formatted the cells as text, but when a CAS # such as 75-08-1 is entered into the cell or when that text string is manipulated by excel, it tends to return the string as a Date (1975-08-1) and then translates it back to a serial number and displays that as text (27607).

    I need to search on the string as originally entered and I cannot prevent excel from making this false decision on its own.


    How can I keep a string such as 75-08-1 as text, rain or shine! Preferably without adding another character to the string.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Excel changes formatting of certain strings.

    Hi dhAndrews and welcome to the forum,

    If you start entering these numbers with an apostrophe (single quote) your data will be taken as text instead of converted to a date.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    10-17-2016
    Location
    Saugatuck, MI
    MS-Off Ver
    Office 365 (2016)
    Posts
    3

    Re: Excel changes formatting of certain strings.

    Thanks Marvin

    I knew of and played with that solution, however, excel still wants to note that entry as a date and gives a green triangle note to you. Even if I respond to the error message and tell excel to leave it as text, if I copy or manipulate that string, it will restore the error message and if I do not respond, it WILL change it to a date in the future ('75-06-1 will show the error mark to alert me that this should be a date) and I will end up with either "1975-06-01" or the serial equivalent of it (27546).

    This is a value I want users to be able to perform a lookup on and I would require the user to remember to insert the ' before the search data, and the probability of returning the correct data would always be less than 100% which is unacceptable.

    I fear that Excel is not the tool for this application because of this software shortcoming!

  4. #4
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    Massachusetts
    MS-Off Ver
    365(PC) V:2308
    Posts
    1,472

    Re: Excel changes formatting of certain strings.

    go to file
    - options
    - Formulas
    unselect "Enable background error checking"

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Excel changes formatting of certain strings.

    I occasionally work with CAS numbers as well, but I cannot recall having this same difficulty. I have participated in some discussions that suggest that different versions of Excel behave a little differently when it comes to automatically converting an entered string to date like this.

    I wish there was a setting somewhere in Excel like "never auto convert values to dates". However, I am a little suprised that you indicate that Excel will eventually autoconvert these strings to dates in spite of the steps you have taken. I think it would be instructive if you could provide specific examples of when Excel will autoconvert these strings to dates. What you did to prevent the conversion, and what you were doing with the data when it autoconverted.

    If interested, I am reminded of this discussion from earlier this year. We went round and round the problem until about post 26, where it was noticed that Excel 2016 appeared to be converting his text strings to dates during the processing (my copy of 2007 did not convert the strings to dates) http://www.excelforum.com/excel-gene...rediction.html . His solution was to not use "-" as his delimiter. In your case, CAS numbers have a long tradition of being displayed with "-" as the delimiter, so there is a stronger tradition here to use the "-". But it illustrates what I mean about how different versions of Excel can behave differently, and it illustrates what I mean by understanding exactly what you are doing when Excel auto-detects and converts to date.

    I would note that you should be able to recover the text string after Excel converts to date using the TEXT() function, though it is really frustrating to us users of Excel to have to use such a "band-aid" when the real solution is for Excel to not autoconvert to date in the first place.

    Anyway, all of that said, I would suggest that you provide some examples of exactly what you are trying to do when Excel autoconverts and let us see if we can help you devise a way for Excel to not mess up your CAS numbers.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Registered User
    Join Date
    10-17-2016
    Location
    Saugatuck, MI
    MS-Off Ver
    Office 365 (2016)
    Posts
    3

    Re: Excel changes formatting of certain strings.

    DOSydos, et al,

    OK I found it. went slightly farther than suggested by D&D and deselected "cells containing years as two digits"

    Thanks to all.

    See you all in a day or so when I have another question - I know I will....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Moved to commercial services forum.
    By Midnight-Oil in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-28-2015, 01:05 PM
  2. Replies: 5
    Last Post: 06-12-2014, 09:23 AM
  3. excel formula to search Multiple strings in several columns and return strings
    By krratna123 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-13-2013, 11:20 AM
  4. Replies: 1
    Last Post: 08-13-2013, 08:32 AM
  5. Joining text strings with "some" formatting in Excel 2008
    By Dano in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-06-2008, 05:13 AM
  6. Formatting concatenated strings
    By ions in forum Excel General
    Replies: 2
    Last Post: 02-22-2008, 04:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1