+ Reply to Thread
Results 1 to 8 of 8

If statement returning part of a cell between special characters

  1. #1
    Registered User
    Join Date
    04-20-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2013, 2010, 2007, 2003
    Posts
    99

    If statement returning part of a cell between special characters

    I have a data set with 5 types of entry that begin with <xxxx>value i want</xxxx>. What I'd like to do is have an if statement that determines what the xxxxx type is and then returns the value between the >< marks. I've got the if statement part figured out, but I cant figure out how to extract the internal value/trim the tail because the number of characters varies.

    Please see attached for further clarification

    if_statement_results_between_chars.xlsx

    Thank you!

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: If statement returning part of a cell between special characters

    Try

    =MID(B3,FIND(">",B3)+1,FIND("^",SUBSTITUTE(B3,"<","^","2"))-FIND(">",B3)-1)

    I don't know how I came up with that formula.....but it works

  3. #3
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: If statement returning part of a cell between special characters

    Maybe this
    =MID(A2,FIND(">",A2)+1,FIND("</",A2)-FIND(">",A2)-1)

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: If statement returning part of a cell between special characters

    Try:

    =MID(B3,(FIND(">",B3,2))+1,(FIND("<",B3,2))-(FIND(">",B3,2))-1) and copy down.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: If statement returning part of a cell between special characters

    If you want to avoid formula, use TextToColumn, TWICE.

  6. #6
    Registered User
    Join Date
    04-19-2004
    Location
    Palmerston North, New Zealand
    MS-Off Ver
    365
    Posts
    15

    Re: If statement returning part of a cell between special characters

    Does it have to be done with a formula? I managed to achieve the desired results by using Data>Text to Columns and delimiting the data first on ">" and then "<"

  7. #7
    Registered User
    Join Date
    04-20-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2013, 2010, 2007, 2003
    Posts
    99

    Re: If statement returning part of a cell between special characters

    Thank you all, these all work very nicely

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: If statement returning part of a cell between special characters

    You're welcome. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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