+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : If contains "text" then "Write this" or "This"

  1. #1
    Forum Contributor
    Join Date
    02-14-2012
    Location
    Warrington
    MS-Off Ver
    Excel 365
    Posts
    497

    If contains "text" then "Write this" or "This"

    If cell contains certain text.xlsx

    I want any cell that contains:

    mal to say MAL
    len to say LEN
    sol to say SOL
    atlas to say MAL

    I have done an if statement and it only works for the first true outcome, it does not seem to carry on the arguement if false like a normal if statement?

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: If contains "text" then "Write this" or "This"

    Hi,

    Try this:

    =IF(ISNUMBER(SEARCH("mal",A2)),"MAL",IF(ISNUMBER(SEARCH("atlas",A2)),"MAL",IF(ISNUMBER(SEARCH("len",A2)),"LEN",IF(ISNUMBER(SEARCH("sol",A2)),"SOL",""))))
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Contributor
    Join Date
    02-14-2012
    Location
    Warrington
    MS-Off Ver
    Excel 365
    Posts
    497

    Re: If contains "text" then "Write this" or "This"

    Worked a treat thanks very much!

    Just so I understand, what is the isnumber formula? I feel silly because it makes me think if its a number then search, but this is text and numbers?

  4. #4
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: If contains "text" then "Write this" or "This"

    On its own, the function =SEARCH(find_text,within_text) will return the position of find_text in the string that is within_text, and if not present, return an error.

    so,

    =SEARCH("rent","Current") will return 4, as "rent" is at the 4th character of "Current"

    =SEARCH("rent","Sultana") will return #VALUE as "rent is not present in "Sultana"


    =ISNUMBER(value) returns either true or false depending on whether or not value is a number, so,

    =ISNUMBER(SEARCH("rent","Current")) will return TRUE
    =ISNUMBER(SEARCH("rent","Sultana")) will return FALSE

+ 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