Search code examples
excelexcel-formulaexcel-2010excel-2007

How to compare two columns in excel (with little different criteria)


Hi i have two columns(list of username and list of girl names) like below

enter image description here

Username girlname Expected output John Dennies Lina boy Barak Obama Savita boy Lina Josef Lynn girl Amanda wolve vaneesa girl Jerry J. Walt amanda boy Linac M take boy

Girlname contains list of 5000+ names. Now i want column 1 (username ) to be compared against the girlname and whenever there is a match it should display a "match" in another column where i will put the condition. Problem is as girlname is just a substring of the column one .its very difficult for a novice like me to generate the formula. I have formula which works for exact match but this query is little different than the usual ones hope i get an answer here.


Solution

  • Use the following formula:

    =IF(SUMPRODUCT(ISNUMBER(SEARCH($B$2:$B$6& " ",A2))*1)>0,"Girl","Boy")
    

    It will search the girls name column to see if any match any but the last name. If so it will return Girl if not Boy.

    enter image description here