+ Reply to Thread
Results 1 to 6 of 6

Formula that takes takes out a specific word/number from text string

  1. #1
    Registered User
    Join Date
    11-05-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    7

    Formula that takes takes out a specific word/number from text string

    Hello all,

    I need a hand creating a formula that will take the 2nd word/number/code in a text which has "-" seperating each word/number/code.

    For example, in cell A1, there would be the text "EC12345-TASK01-TESTA"

    I would then want cell B1 to *** out "TASK01" only

    I originally used the "text to columns" menu option to separate the text and just delete the columns I didn't need. However, I've been told dumb down (i.e. remove extra steps) the sheet so that as soon as the original text is entered in one column, the 2nd word/number/code in each string is shown in the next column.

    I've attached an example sheet with some dummy data. column A shows the text and column B should show the 2nd word/number/code (first row has been down as an example of the result expected).

    P.S > I have Excel 2010

    Regards

    Nic
    Attached Files Attached Files
    Last edited by ncalvelo; 11-29-2012 at 11:24 AM. Reason: Solved

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Formula that takes takes out a specific word/number from text string

    hi Nic, welcome to the forum. how about:
    =TRIM(MID(SUBSTITUTE(A2,"-",REPT(" ",50)),51,50))

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Formula that takes takes out a specific word/number from text string

    Hi

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    11-05-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Formula that takes takes out a specific word/number from text string

    Quote Originally Posted by benishiryo View Post
    hi Nic, welcome to the forum. how about:
    =TRIM(MID(SUBSTITUTE(A2,"-",REPT(" ",50)),51,50))
    This worked perfectly, thanks!

    I've tried breaking down the formula to understand how it works, but I am a bit confused. What I got so far is that you replaced a number of characters in the cell with spaces using SUBSTITUTE and MID so that you were only left with the desired set of characters that makes up the second word. then used TRIM to remove the spaces.

    I don't understand how the MID and SUBSTITUTE part of the formula worked, any chance you (or someone) could explain that part of the formula?

    Thanks again for the help

    Nic

  5. #5
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Formula that takes takes out a specific word/number from text string

    you can use the F9 key to highlight parts of the formula to see the results. for eg,
    SUBSTITUTE(A2,"-",REPT(" ",50))
    this portion will replace all "-" with 50 spaces & give you:
    "EC12345 TASK01 TEST"

    using the MID formula to retrieve the 51st character onwards & obtain 50 characters will return me a bunch of spaces & the texts in between:
    " TASK01 "

    the TRIM formula will then take care of all extra spaces

    Edit: the post seemed to have disallowed my illustration of many spaces. so please try this formula by using the F9 key inside the formula
    Last edited by benishiryo; 11-29-2012 at 10:29 AM. Reason: additional info

  6. #6
    Registered User
    Join Date
    11-05-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Formula that takes takes out a specific word/number from text string

    Got it, Thanks!

    Nic

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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