+ Reply to Thread
Results 1 to 9 of 9

Retrieving the a string from a sentence

  1. #1
    Registered User
    Join Date
    02-13-2009
    Location
    sg
    MS-Off Ver
    Excel 2007
    Posts
    36

    Retrieving the a string from a sentence

    =IFERROR(SEARCH("[",string,1),MID(string position,start of char,length of char))

    Hi I wish to pull out the characters from a sentence. Once it detects the "[" from the sentence it should pull the string that follow limiting to the length of the character.

    It looks like I did something wrong and the results shows only the position of "[" only.

    I want to error check because it to return nuthing if there's no value. IF statement would process errors in this case.

    Any help to get this right.
    thanks
    Last edited by superkid; 02-14-2009 at 10:25 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Retrieving the a string from a sentence

    Show us some sample strings and clarify what you want out of those examples.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Retrieving the a string from a sentence

    A few things:

    1 - please PM a Moderator to have your thread moved a more appropriate Forum (Worksheet Functions)

    2 - IFERROR is only available in 2007, your profile implies you're running 2003 in which case I'm afraid you can't use it

    I think perhaps you mean:

    =IF(ISNUMBER(SEARCH("[",string,1)),MID(string,SEARCH("[",string,1)+1,LEN(string)),"")

    string should obviously be a cell reference

  4. #4
    Registered User
    Join Date
    02-13-2009
    Location
    sg
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Retrieving the a string from a sentence

    I apologize for posting in the wrong forum and will pm the moderator.

    My system was just upgraded to the 2007 system. Btw I am having problems uploading the sample worksheet.

    Thank you .

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Retrieving the a string from a sentence

    To use IFERROR here just adapt that provided to:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-13-2009
    Location
    sg
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Retrieving the a string from a sentence

    thank you

    but this will return the length of the string right But i would like to get the content from the string.

    For example
    i went to the [see,saw] to play.

    Expected result should return see,saw
    The function should detect the braces and enter the value and nothing when it does not detect the braces.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Retrieving the a string from a sentence

    The prior function would not return the LEN - please have the courtesy to test solutions before dismissing.

    As is it also helps to state your question as clearly as possible... you make no mention of ] in your initial post, to get your desired results:

    Please Login or Register  to view this content.
    Where A1 is your string.

    If you're using the above to retrieve a filename from a path you can obviously insert CELL("filename") as opposed to A1.

  8. #8
    Registered User
    Join Date
    02-13-2009
    Location
    sg
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Retrieving the a string from a sentence

    Thank you so much. Got it running. I admit it was my mistake. I subtracted the length of the string wrongly.

    Please Login or Register  to view this content.
    Thanks a millions.

  9. #9
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: Retrieving the a string from a sentence

    Thread moved as requested by OP

+ 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