+ Reply to Thread
Results 1 to 9 of 9

using the MID function

  1. #1
    Forum Contributor
    Join Date
    04-29-2012
    Location
    nuneaton, England
    MS-Off Ver
    Office 365
    Posts
    370

    using the MID function

    I have got most of this formula working ok but I cant work out how to do the length.

    I have a name that I am trying to split (I am wanting the first name)

    Currently I have =MID(A2, SEARCH(", Dr ",A2,1)+5, 15) but That is 15 characters. What I would like is to take it to the next SPACE after.

    IE

    Smith, Dr John Peter Andrew would return just John and
    Jones, Dr Elizabeth Mary Louise would return Elizabeth

    Can anyone help me finish off the formula please.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,135

    Re: using the MID function

    Still using Excel 2007?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Forum Contributor
    Join Date
    04-29-2012
    Location
    nuneaton, England
    MS-Off Ver
    Office 365
    Posts
    370

    Re: using the MID function

    no.. office 365. i will update my profile

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,135

    Re: using the MID function

    Maybe:

    =LEFT(MID(A1, SEARCH(", Dr ",A1,1)+5, 255),SEARCH(" ",MID(A1, SEARCH(", Dr ",A1,1)+5, 255)))

    if you have a more modern excel, there are cleaner alternatives.
    Attached Files Attached Files

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,135

    Re: using the MID function

    Cleaner version for O365:

    =TEXTBEFORE(TEXTAFTER(A1,"Dr ")," ")
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    04-29-2012
    Location
    nuneaton, England
    MS-Off Ver
    Office 365
    Posts
    370

    Re: using the MID function

    that works fine. ty.. but i am getting an #value error id its just Smith, Dr John as it doesnt have that extra space on the end. i suppose i could use the right function as an iferror

  7. #7
    Forum Expert Colin Legg's Avatar
    Join Date
    03-30-2008
    Location
    UK
    MS-Off Ver
    365
    Posts
    1,256

    Re: using the MID function

    Here's another way in O365. It splits the text by the spaces into an array and then picks the 3rd item:

    =INDEX(TEXTSPLIT(A2," "),3)
    Hope that helps,

    Colin

    RAD Excel Blog

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,135

    Re: using the MID function

    True, but it would fall over for non-hyphenated double-barreled surnames.

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,135

    Re: using the MID function

    =TEXTBEFORE(TEXTAFTER(A1&" ","Dr ")," ")

    will ensure that it works in the case mentioned at Post 6.

+ 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. Replies: 1
    Last Post: 02-10-2023, 10:18 AM
  2. [SOLVED] Left function, Right Function, or Mid Function to extract values to three decimal places
    By bjnockle in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-08-2023, 03:22 AM
  3. Right function, Left function, Mid function to extract values in column A
    By bjnockle in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 06-14-2020, 03:14 PM
  4. COUNTUNIQUE Function in Google Sheets; Excel lacks a direct counterpart to this function?
    By PivotTablePSHomage in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-18-2018, 05:27 AM
  5. Calling function inside function. (aka nested function)
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2015, 05:58 AM
  6. Replies: 13
    Last Post: 04-08-2014, 05:46 AM
  7. Replies: 1
    Last Post: 03-21-2012, 11:22 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