+ Reply to Thread
Results 1 to 5 of 5

Nesting if statements when a partial word match is found

  1. #1
    Registered User
    Join Date
    11-28-2011
    Location
    Marshfield, Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    12

    Nesting if statements when a partial word match is found

    Good Day,

    I a spreadsheet that i need to return multiple catagories if certain words are matched.

    For example:

    C2 may contain "Kwik Trip" or "the Store" or "Hal's Supermarket". I want column D2 to return the word "Gas" if A2 has "Kwik Trip" or "the Store" anywhere in it. I want D2 to return the word "Groceries" if column A has "Hals Supermarket" anywhere in it. C2 will contain only one of the qualifiers in it. C2 will however contain more than just those words IE: "KWIK TRIP GAS AND GO" or "THE STORE BREAD AND BUTTER STOP".

    I have tried using the formula =if(c2="*Kwik*","Gas"),if(c2="*The Store*","Gas"),if(c2="*Hals*","Groceries") . This doesn't seem to recognize that I want a return if the partial words are met.

    Thanks!!

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Nesting if statements when a partial word match is found

    Try this

    =IF(OR(ISNUMBER(SEARCH("Kwik Trip",C2)),ISNUMBER(SEARCH("the store",C2))),"True", "False")
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    11-28-2011
    Location
    Marshfield, Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Nesting if statements when a partial word match is found

    Not that I can see. I want a specific word like "Gas" to be returned if C2 = "Kwik" or "Store" or to return the word "grocery" if C2 = "Hals"

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Nesting if statements when a partial word match is found

    Create a 2 column table with the name in the left column and the category in the right column:

    Please Login or Register  to view this content.
    Then, enter this formula in D2:


    =IFERROR(LOOKUP(1E100,SEARCH(H$2:H$4,C2),I$2:I$4),"")
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    11-28-2011
    Location
    Marshfield, Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Nesting if statements when a partial word match is found

    Thanks Biff, worked great. Not the way i was trying to do it but easier than nexting the formula over and over. Just like your tag says "Keep it simple stupid"

  6. #6
    Registered User
    Join Date
    09-06-2018
    Location
    US
    MS-Off Ver
    16
    Posts
    1

    Re: Nesting if statements when a partial word match is found

    worked for me too!! however, what would it be if you didn't want to have the extra data set and did want to nest them?

+ 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