+ Reply to Thread
Results 1 to 3 of 3

sub string search returning multiple values

  1. #1
    Registered User
    Join Date
    05-23-2012
    Location
    A of US
    MS-Off Ver
    Excel 2010
    Posts
    3

    Question sub string search returning multiple values

    Hi All,

    First time on the board, glad I found this site!

    I'm trying to build a formula that searches for multiple sub-strings and returns specific values based on what it finds.

    I started off by first writing; =IF(OR(SEARCH("Prep", H3,1),SEARCH("Tail",H3,1),SEARCH("Custom",H3,1),),"Flagged"," ") I thought this would at least return the word "Flagged", but its not working.

    I then tried; =IF(OR(SEARCH("*"&Prep&"*", H2,1),SEARCH("*"&Tail&"*",H2,1),SEARCH("*"&Custom&"*",H2,1),),"Flagged"," "). Returned #Name?

    then; =IF(OR(H2="*"&Prep&"*",H2="*"&Tail&"*",H2="*"&Custom&"*"),"Custom"," ") Returned #Name?

    then; =IF(H2="*"&Prep&"*","Prep Session",IF(H2="*"&Tail&"*","Tailored",IF(H2="*"&Custom&"*","Custom"))) returned #Name?

    I'm stumped ...

    I want to accomplish the last if statement logic by returning a value for each sub-string parameter found. Any help is appreciated.

    Thanks,
    ABL

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,418

    Re: sub string search returning multiple values

    Try it this way instead:

    =IF(COUNTIF(H2,"*prep*")+COUNTIF(H2,"*tail*")+COUNTIF(H2,"*custom*")>0,"Flagged","")

    Hope this helps.

    Pete

  3. #3
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    365
    Posts
    2,243

    Re: sub string search returning multiple values

    Hi, ABL,

    You can reduce Pete's formula to,

    =IF(SUM(COUNTIF(H2,"*"&{"prep","tail","custom"}&"*")),"flagged","")

    Or with SEARCH,

    =IF(COUNT(SEARCH({"prep","tail","custom"},H2)),"flagged","")
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

+ 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