+ Reply to Thread
Results 1 to 6 of 6

Text to Columns

Hybrid View

  1. #1
    Registered User
    Join Date
    01-07-2014
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    2

    Text to Columns

    Hi All. I've been trying to automate a process that I have to do every day at work without having to use VBA. Hoping someone can help.

    I import data into a column that has a string of text followed by a hyphen and 8 numbers. An example would be "Sonoma Country - 13456-094". My goal is to take the 8 numbers "*****-***" and put it in the column over. A1 would then be "Sonoma Country" & B1 would be 13456-094.

    I usually find and replace " - " with "*" and use text to columns to separate the text from the numbers. However, sometimes the data can be "Sonoma Country - (CA) - 13456-095" at which point this process no longer works. "(CA)" is in B1 & the numbers are in C1.

    Is there a formula make sure the 8 digits are always in column B? No text or numbers ever follow the 8 digits which may help solve this problem.

    Thanks!
    Mike

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Text to Columns

    Try this

    in B1

    =SUBSTITUTE(LEFT(A1,FIND("-",A1)+1)," - ","")

    In C1

    =TRIM(SUBSTITUTE(SUBSTITUTE(A1,B1,""),"-","",1))

    A
    B
    C
    1
    Sonoma Country - 13456-094 Sonoma Country 13456-094
    2
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,421

    Re: Text to Columns

    If it is always 8 digits (and a hyphen), then you can put this formula in B1:

    =TRIM(LEFT(A1,LEN(A1)-9))

    and this one in C1:

    =RIGHT(A1,9)

    Copy both formulae down to the bottom of the data in column A. An easy way to do this is to select cell B1 and double-click the fill handle (the small black square in the bottom right corner of the cursor). Then do the same for C1.

    Then select columns B and C and fix the values, i.e. click <copy>, then right-click in that area and select Paste Special, then click Values, then OK then press the <Esc> key. Then you can delete the original column A.

    Hope this helps.

    Pete

  4. #4
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,658

    Re: Text to Columns

    =TRIM(LEFT(A1,LEN(A1)-12))
    =RIGHT(A1,9)

    Try these 2 formulas
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  5. #5
    Registered User
    Join Date
    01-07-2014
    Location
    NYC
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Text to Columns

    Thanks Pete! Your answer with a few tweaks on my end worked like a charm. Appreciate your and everyone else's help.

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,421

    Re: Text to Columns

    Well, that's good to hear - thanks for feeding back.

    If that takes care of your original question, please select Thread Tools from the menu above your first post and mark this thread as SOLVED.

    Also, since you are relatively new to the forum, I would like to inform you that you can directly thank those who have helped you by clicking on the small "star" icon located in the lower left corner of a post that you have found to be helpful (not just in this thread - for any post that has helped you). This also adds to the reputation of the poster (the small green bars in the poster's profile).

    Pete

+ 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. pull text from 2 columns based on finding text in other columns
    By jimcuk in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-03-2013, 09:21 AM
  2. Replies: 1
    Last Post: 03-09-2013, 02:55 PM
  3. MAcro to - copy, transpose, text to columns, remove column A, combine all columns in 1
    By galvinpaddy in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 02-07-2013, 08:48 AM
  4. Formula to align two columns with nearly similar text and attached numeric columns
    By Benefits Recon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2012, 12:03 AM
  5. Linking text columns with text and data columns
    By Edd in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-17-2005, 01:06 PM

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