+ Reply to Thread
Results 1 to 3 of 3

is there an equal fxn for 'InStr' in excel. Not Find or Search

  1. #1
    Clausius
    Guest

    is there an equal fxn for 'InStr' in excel. Not Find or Search

    I find "InStr" quite usefull in Access and am curious if there is an
    equivalent in excel. I've tried Find and Search but they don't return the
    actual string of interest, they just tell you true or false (return 1 or 0).

  2. #2
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    There may be better ways, but this will work.

    Assuming you are looking for the string "Data" in cell C22 (containing "All Data Available)", use this formula:

    =IF(FIND("Data",C22)>0,MID(C22,FIND("Data",C22,1),LEN("Data")),"oops")

    Returns "Data" if found, otherwise returns "oops"

    note: a cell reference can be used instead of the actual string, assuming the string "Data" in in cell C26:

    =IF(FIND(C26,C22)>0,MID(C22,FIND(C26,C22,1),LEN(C26)),"oops")

    returns "Data"

    also note that Find is case sensitive, e.g. "data" in C26 will return "oops".


    HTH

    Bruce
    Bruce
    The older I get, the better I used to be.
    USA

  3. #3
    Arvi Laanemets
    Guest

    Re: is there an equal fxn for 'InStr' in excel. Not Find or Search

    Hi

    From Excel VBA help (about InStr VBA function):
    InStr Function: Returns a Variant (Long) specifying the position of the
    first occurrence of one string within another.
    Syntax: InStr([start, ]string1, string2[, compare])

    From Excel help (about FIND worksheet function):
    FIND finds one text string (find_text) within another text string
    (within_text), and returns the number of the starting position of find_text,
    from the first character of within_text. You can also use SEARCH to find one
    text string within another, but unlike SEARCH, FIND is case sensitive and
    doesn't allow wildcard characters.
    Syntax: FIND(find_text,within_text,start_num)


    As you see, none of them returns a string (and neither does Access InStr
    function) - all of them return the starting position of one string in
    another.


    Arvi Laanemets



    "Clausius" <[email protected]> wrote in message
    news:[email protected]...
    > I find "InStr" quite usefull in Access and am curious if there is an
    > equivalent in excel. I've tried Find and Search but they don't return the
    > actual string of interest, they just tell you true or false (return 1 or

    0).



+ 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