+ Reply to Thread
Results 1 to 6 of 6

Function that enables me to extract text in the middle of a cell

  1. #1
    Registered User
    Join Date
    02-25-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    2

    Function that enables me to extract text in the middle of a cell

    Hi

    Could someone give me a hand with the following.

    I need to extract text from the middle of a cell. I know you can use the MID function but need help with the complete function as i need to extract text string from Name to the end of their full name (I have highlighted below in bold). Of course their full name will change in each row.

    Example text in cell B2: ID: 197993043 Name: Ben Fred Company: ID: 197992821 Name: Hello World!

    A2 cell: =MID(B2,15,??????

    Any suggestions would be great as its been a while since I've used Excel.

    Many thanks!

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Function that enables me to extract text in the middle of a cell

    try:
    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    02-25-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Function that enables me to extract text in the middle of a cell

    Thanks Kaper but could you explain the -16?

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Function that enables me to extract text in the middle of a cell

    FIND("Company:",B2) is a position in B2 letter C (from "Company:")
    so now you know how many charcacters are before Company.
    Before there is space so you need this position -1
    but ... you dropped first 15 characters from the left so -15
    -1-15 = -16
    and that: FIND("Company:",B2)-16 is the length of substring you want to extract.

    Of course, instead of "hardcoding" 15, you could also use another FIND to determine the start of substring.
    Last edited by Kaper; 02-25-2014 at 03:50 PM.

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

    Re: Function that enables me to extract text in the middle of a cell

    =MID(B2,FIND("Name",B2,1),FIND("Company:",B2)-1-FIND("Name",B2,1)+1)
    Take a look at this.
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Function that enables me to extract text in the middle of a cell

    Hi Willem,
    Taking seriously what you have written in the signature:
    Your formula will return too long substring (extra space at the end):
    >Name: Ben Fred <
    Adding one at the end makes anyway no sense from mathematical point of view, as you are subtracting it earlier, so after some rearrangement it would be:
    =MID(B2,FIND("Name",B2,1),FIND("Company:",B2)-FIND("Name",B2,1)-1+1)

    Anyway, right version is:
    =MID(B2,FIND("Name",B2,1),FIND("Company:",B2)-1-FIND("Name",B2,1))

    and this is exactly what I ment:
    Of course, instead of "hardcoding" 15, you could also use another FIND to determine the start of substring.

+ 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. Extract Data from Middle of Cell
    By narrowgate88 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2012, 06:49 PM
  2. Extract number in the middle of text (check from right-to-left)
    By diywho in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-20-2012, 05:21 AM
  3. Extract text from the middle of a string for concatenation
    By christopherp in forum Excel General
    Replies: 1
    Last Post: 05-16-2011, 08:55 AM
  4. Extract 1, 2 or 3 words from middle of text in a cell
    By Vinnie Chan in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-31-2010, 02:55 PM
  5. Extract number in middle of cell
    By Jason Morin in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 04:05 AM

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