+ Reply to Thread
Results 1 to 6 of 6

Finding text in an equation

  1. #1
    Registered User
    Join Date
    07-11-2008
    Location
    Sweden
    Posts
    13

    Finding text in an equation

    I want to find a text string within another cell. I can do this easily using an IF function and a FIND function if the other cell contains a simple text string. However, this doesn't work if the text I'm trying to find is embedded in an equation.

    For example, I want to find the text "Sheet1" in another cell that has an equation =Sheet1!A7. When it finds the text there, then I want the result TRUE. If it doesn't find the text then I want FALSE.

    Any ideas?!?

  2. #2
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256

    One option

    One option is to use a so called User Defined Function. In other words, your make your own function.

    1. Press Alt+F11 and Select from the menu: Insert, Module
    2. Copy and paste the below in that module:
    Function GetFormula(Cell as Range) as String
    GetFormula = Cell.Formula
    End Function
    3. Close the VBA window and go back to your Spreadsheet and start use the new formula (UDF). I.e =FIND("Sheet";GetFormula)

    Hope it helped
    //Ola

  3. #3
    Forum Contributor
    Join Date
    06-14-2008
    Posts
    153
    Hi,

    Another option:

    Create the following function and use it directly without the need to use the FIND function.
    Please Login or Register  to view this content.
    This function accepts two arguments: the text to look for and the cell reference where the formula is.

    If you need help on how to create a user defined function see this link:

    http://www.exceldigest.com/myblog/20...ined-function/
    Welcome to: http://www.exceldigest.com/myblog/
    "Excel help for the rest of us"

  4. #4
    Registered User
    Join Date
    07-11-2008
    Location
    Sweden
    Posts
    13
    Thanks for the tip. I was hoping I would be able to avoid VBA. The people who will be using the spreadsheet have a bit of a VBA phobia! Is there any chance that there's an existing Excel function that will do the same job? If not, then I think I will do some sort of less elegant work-around!

    Thanks again, Helen

  5. #5
    Registered User
    Join Date
    07-11-2008
    Location
    Sweden
    Posts
    13
    Thanks for the other option se1429! I copied the code into a new module. Then closed and went back to Excel. I put the formula "=Sheet2!C2" into cell A1. Then in cell A2 I put the formula "=FoundInFormula("Sheet",A1)" and it returned the result TRUE. Perfect!

    The only funny thing I've found with it is that it's case sensitive so if I type "sheet" instead of "Sheet" then it returns FALSE. But for what I need it for that's no problem.

    Thanks so much! Helen

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    The only funny thing I've found with it is that it's case sensitive ...
    A minor change:
    Please Login or Register  to view this content.

+ 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