1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

split a string in 2 cells in excel

Discussion in 'Other PC Software' started by maxmangion, 2004/05/13.

Thread Status:
Not open for further replies.
  1. 2004/05/13
    maxmangion

    maxmangion Inactive Thread Starter

    Joined:
    2002/08/13
    Messages:
    252
    Likes Received:
    0
    in an excel sheet i have a string in the following format written in a cell:

    italy - rome
    england - london
    france - paris
    etc

    now i want to split the above string into 2 cells e.g

    cell1 cell2
    italy rome
    france paris
    england london

    can someone pls remind how i can do it pls in excel, because i remember myself doing it in the past using some sort of Function, but i can't figure out which function i used to use.

    thank you!
     
  2. 2004/05/14
    merlin

    merlin Inactive

    Joined:
    2003/01/07
    Messages:
    1,111
    Likes Received:
    0
    Not sure, but maybe the function you were using was Concat() where you
    specify the new cell contents as a concatinated value of another cell.
    regards
     

  3. to hide this advert.

  4. 2004/05/14
    Davheili

    Davheili Inactive

    Joined:
    2002/01/07
    Messages:
    36
    Likes Received:
    0
    For a one time run, try

    Data / Text to Columns

    On the 3rd screen of the wizard, you can even specify a new location to put the results into so that you don't need to mess with the original cells.

    Have fun. :)
     
  5. 2004/05/18
    maxmangion

    maxmangion Inactive Thread Starter

    Joined:
    2002/08/13
    Messages:
    252
    Likes Received:
    0
    i've managed to achieve it by using this formula:

    =LEFT(A1,FIND( "- ", A1)-1) = "italy "

    =MID(A1, (FIND( "- ",A1)+2), 10) = "rome "

    However, your idea of converting text to columns and using the "-" as the delimeter is much easier.

    thank you!
     
  6. 2004/05/19
    ReggieB

    ReggieB Inactive Alumni

    Joined:
    2004/05/12
    Messages:
    2,786
    Likes Received:
    2
    Use of MID

    One problem with Maxmangion's solution is that if the section after the "-" is greater than 10 characters, the end of the string will be truncated. For example "USA - Washington DC" would return "Washington" without the DC.

    =MID(A1,(FIND( "- ",A1)+2),(LEN(A1)-FIND( "- ",A1)))

    Would overcome this but is a little unweildy. An alternative would to be to add another column (B perhaps) with

    =FIND( "- ",A1)

    And then use the cells in that column in the final column

    =MID(A1,(B1+2),(LEN(A1)-B1))
     
  7. 2004/05/19
    ReggieB

    ReggieB Inactive Alumni

    Joined:
    2004/05/12
    Messages:
    2,786
    Likes Received:
    2
    Use right

    Thinking about it, using RIGHT would be easier still

    =RIGHT(A1,LEN(A1)-FIND( "- ",A1)-1)
     
Thread Status:
Not open for further replies.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.