+ Reply to Thread
Results 1 to 3 of 3

Like function in an If statement

Hybrid View

  1. #1
    Registered User
    Join Date
    06-21-2011
    Location
    Queensland
    MS-Off Ver
    Excel 2010
    Posts
    2

    Like function in an If statement

    Hi,

    I love using the like function in excel - "*"&cell&"*"

    At the moment I am trying to use that within an if statement and I can't make it work - this is what I am trying to do.

    =if(A1="*"&A2&"*","OK",0) - it works for sumif, lookups etc.

    I need to compare two lists of suburbs - if they match, or are similar I need an OK, and if they are not to flag them.

    Any ideas? I don't know how to use VBA very well.

    Many thanks

    Sam
    Last edited by Samantha78; 06-28-2011 at 02:34 AM.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Help - I'd like to use a like function in an if statement

    Perhaps one of these regular formulas will work for you:
    =IF(COUNTIF(A1,"*"&A2&"*"),"OK",0)
    or...with some meageer error checking:
    =IF((A2<>"")*COUNTIF(A1,"*"&A2&"*"),"OK",0)
    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    06-21-2011
    Location
    Queensland
    MS-Off Ver
    Excel 2010
    Posts
    2

    SOLVED Re: Like function in an If statement

    Thank you it works well!

+ 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