+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : Numbers formatted as text are not being treated as text

  1. #1
    Registered User
    Join Date
    08-03-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    7

    Numbers formatted as text are not being treated as text

    I am working with two data sets that have two different formats
    for an Assessor's Parcel Number (APN)

    One is a simple eight-digit number: 00102001

    The other is hyphenated, and may or may not have
    an additional two digits: 001-020-01-00, or 001-020-01

    I need to remove the hyphens, and truncate the left most digits in
    those that contain 10 digits, to convert the hyphenated APN's to
    the simple eight-digit format.

    When I use the replace command to replace the hyphens with nothing,
    leading zeroes are deleted. e.g.: 000-000-00-00 becomes simply 0
    and 001-040-14 becomes 104014.

    This is happening even when the numbers have been formatted as text.

    How can I prevent the zeroes from being deleted?

    Also, how can I truncate the numbers to the right-most eight digits?

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Numbers formatted as text are not being treated as text

    Have you considered using functions. For example below.

    =IF(NOT(ISERROR(SEARCH("-",A1))),LEFT(SUBSTITUTE(A1,"-",""),LEN(SUBSTITUTE(A1,"-",""))-2),A1)

    This will return 00102001 from 001-020-01-00. Then copy formulas results and paste them as values anywhere. Visit this page if you are not sure how to do that.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Registered User
    Join Date
    08-03-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Numbers formatted as text are not being treated as text

    Yes,

    I ended up using the Left and Substitute functions to get rid of the hyphens and then, spaces,
    and to truncate the numbers.

    Thanks for your response.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Numbers formatted as text are not being treated as text

    Fwiw

    =LEFT(SUBSTITUTE(A1,"-",""),8)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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