+ Reply to Thread
Results 1 to 7 of 7

Formula to search range for either or both values, ignoring blanks

  1. #1
    Forum Contributor
    Join Date
    10-22-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    162

    Formula to search range for either or both values, ignoring blanks

    Hi,

    I'm usually pretty good with formulas but my minds drawing a blank on this one. I've tried googling but either I'm not articulating what I need clearly or no-one else has asked the question before (I suspect the former!).

    I have a range of cells, lets say B5:B10, that I want to search. That range may contain the value "UK", "Intl" or be blank.

    I'd like a formula to search the range and if it only finds UK, return UK, if only Intl, return Intl - or if both UK and Intl then return UK / Intl.

    Sounds simple enough but just not sure which formula would be best to use - vLookup, match...?

    Being a bit dim... TC

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.89 for Mac MS 365
    Posts
    8,575

    Re: Formula to search range for either or both values, ignoring blanks

    Sounds like an IF stmt should work.
    =IF(B5="UK","UK",IF(B5="Intl","Intl",IF(B5="UK/Intl","UK/Intl","")))
    if i'm interpreting your needs correctly.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Formula to search range for either or both values, ignoring blanks

    Try

    =TRIM(IF(ISNUMBER(MATCH("*UK*",B5:B10,0)),"UK","")&" "&IF(ISNUMBER(MATCH("*Intl*",B5:B10,0)),"Intl",""))

    It will return "UK Intl" if both are found
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 VersionVersion 2410 Win 11
    Posts
    24,336

    Re: Formula to search range for either or both values, ignoring blanks

    =if(Counta(B5:B10)=countif(B5:B10,"UK"),"UK",if(Counta(B5:B10)=Countif(B5:B10,"Intl"),"Intl","UK/Intl"))

    Try the above.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Contributor
    Join Date
    10-22-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    162

    Re: Formula to search range for either or both values, ignoring blanks

    Thanks for your reply Sambo Kid - if statement would work for just one cell as you say, but I need one formula to search a Range B5:B10...

  6. #6
    Forum Contributor
    Join Date
    10-22-2012
    Location
    London, UK
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    162

    Re: Formula to search range for either or both values, ignoring blanks

    Thanks Ace_XL and alansidman, both of these work nicely!

  7. #7
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.89 for Mac MS 365
    Posts
    8,575

    Re: Formula to search range for either or both values, ignoring blanks

    should have known I was thinking of it too simply. Glad you got the answer though.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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