+ Reply to Thread
Results 1 to 6 of 6

split column into two columns and keep leading zeros

  1. #1
    Registered User
    Join Date
    12-28-2011
    Location
    Honolulu
    MS-Off Ver
    Excel 2010
    Posts
    2

    split column into two columns and keep leading zeros

    I need to split a column into two columns and retain leading zeros. The data would look like this:

    For example, the original cell "ha0902.3" splits so that the first cell is "ha" and the second cell should be "0902.3" but no matter what I do I get "902.3" in the second cell. Also I don't want the result to be a formula but the actual data only. What I really want is to force the format to be text and display all characters but it always seems to treat it as a number.

    I have tried the "Text to Columns" button on the Data ribbon and formatted each column to text and used special formatting but nothing has worked.

    I have also tried:

    Please Login or Register  to view this content.
    to get the second cell, which works except that I end up with a formula in the cell and it displays the apostrophe at the beginning - '0902.3

    Because I have a huge amount of data to convert (by my own standard), I would really like to use "Text to Columns" since it is quick and clean.

    Thanks,
    BuzzMicron

  2. #2
    Registered User
    Join Date
    12-28-2011
    Location
    India
    MS-Off Ver
    2003, 2007 and 2010
    Posts
    34

    Re: split column into two columns and keep leading zeros

    Hi,

    If it sure that before the number if it is always two letters, then you can go for the text to column feature itself, but you need to go for "Fixed Width" option where you have the option where you want to split the text. or you can use the below formula as well

    =--MID(D3,3,LEN(D3)-2)

    Where the D3 is the cell which contains the text.

    Regards,
    Hari

  3. #3
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: split column into two columns and keep leading zeros

    Hello BuzzMicron,

    Assume the text always in the format like,

    Firstlytexts Then numbers. If so try this,

    For text in B1,

    =LEFT(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A1&"0123456789"))-1)

    For Number,

    =SUBSTITUTE(A1,A2,"")

    This will keep the numbers as text in A1
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  4. #4
    Registered User
    Join Date
    12-28-2011
    Location
    Honolulu
    MS-Off Ver
    Excel 2010
    Posts
    2

    Cool Re: split column into two columns and keep leading zeros

    Hari,

    I thought I posted this yesterday, but I guess not.

    Thank you.

    Your formula works perfectly, although it actually appears that the Len function is not required because it seems to not sensitive to the string length variations. It gave me a column of formulas which I was then able to copy the column and paste with "Values and Source Formatting" and I had just the values formatted exactly as I needed them. Thanks again.

    Regarding the "Text to Columns" button, I was not clear. Sorry. All the data is two letters, four digits, a decimal point and then from one to three digits or letters. I was using "Text to Columns" with the "Fixed Width" option but it always drops the leading zero when there is one.

    My sense of directness and simplicity wants "Text to Columns" to work and it also gives me the data and not a formula, which is good, but I will use the MID function and get it done, but if someone knows how to make this other method work, then I would like to know how, but it is not critical at this point. Thank you.

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: split column into two columns and keep leading zeros

    change the column in the text to columns wizard to text as you do it,it normally says general so in the wizard select column and change column data format to text
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  6. #6
    Registered User
    Join Date
    11-09-2011
    Location
    Carrboro, US
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: split column into two columns and keep leading zeros

    Help.jpg

    It can be done like "martindwilson" suggested.

+ 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