# FORMULA TO MATCH TEXT STRING IN 2 COLUMNS

Steel Contributor

# FORMULA TO MATCH TEXT STRING IN 2 COLUMNS

what is the FORMULA TO MATCH TEXT STRING IN 2 COLUMNS?

cell text data string in column A if matches text in column B or C should result "match" in column D, "no match" if otherwise.

9 Replies

# Re: FORMULA TO MATCH TEXT STRING IN 2 COLUMNS

In D2

=IF(COUNTIF(B2:C2,"*"&A2&"*"),"MATCH","NO MATCH")

and copy it down.

# Re: FORMULA TO MATCH TEXT STRING IN 2 COLUMNS

@Subodh_Tiwari_sktneer  formula should look for all cell data in b2 to b3000 and c2 to c3000, how can we include them? thanks

# Re: FORMULA TO MATCH TEXT STRING IN 2 COLUMNS

If you place the formula I proposed in D2 and copy it down, it will return the same desired output you mocked up manually. But it seems I am missing your logic here.

Would you please explain the logic behind your desired output you showed in column D?

e.g. in Column D, you have MATCH in D2 and NO MATCH in D3, can you explain the logic behind these two desired output? Maybe then I would pick the logic and derive a suitable formula to return the desired output.

While explaining the logic, take the value of A2 and A3 and let me know all the manual steps you would take to get the desired output as shown in D2 and D3 in your sample file considering just four rows of data.

All I want to know why D2 has MATCH in it and why D3 has NO MATCH in it?

# Re: FORMULA TO MATCH TEXT STRING IN 2 COLUMNS

A2 matches text string in c5, match; A3 do not match in any cell in column B and C, no match, A4 matches in B3, match; A5 do not match in any cell in B and C, no match

# Re: FORMULA TO MATCH TEXT STRING IN 2 COLUMNS

Thanks for explaining the logic.

In D2

=IF(COUNTIF(\$B\$2:\$C\$3000,"*"&A2&"*"),"MATCH","NO MATCH")

and copy it down.

I have placed the formula in Green Cells in column E in the attached.

Please let me know if you are getting the desired output now.

# Re: FORMULA TO MATCH TEXT STRING IN 2 COLUMNS

@Subodh_Tiwari_sktneer hi. i ma 4 years late to the party. Thank you. This formula will be very helpful to me. Is it possible to get matching sub-text in a separate column? Thank you.

# Re: FORMULA TO MATCH TEXT STRING IN 2 COLUMNS

Taking the same example, let's say you want to return text from the matching row in column F:

=LET(n, MIN(IFERROR(MATCH("*"&\$A2&"*", \$B\$2:\$B\$5, 0),1000000000), IFERROR(MATCH("*"&\$A2&"*", \$C\$2:\$C\$5, 0), 1000000000)), IF(n<>1000000000, INDEX(\$F\$2:\$F\$5, n), ""))

(1000000000 is an arbitrary very large number)

# Re: FORMULA TO MATCH TEXT STRING IN 2 COLUMNS

@HansVogelaar I tried your formula, butI am getting #Name? error message. Thank you for your help.

# Re: FORMULA TO MATCH TEXT STRING IN 2 COLUMNS

The formula that I posted will work in Excel in Microsoft 365 and Office 2021. In an older version, you should be able to use

=IF(MIN(IFERROR(MATCH("*"&\$A2&"*", \$B\$2:\$B\$5, 0),1000000000), IFERROR(MATCH("*"&\$A2&"*", \$C\$2:\$C\$5, 0), 1000000000))<>1000000000, INDEX(\$F\$2:\$F\$5, MIN(IFERROR(MATCH("*"&\$A2&"*", \$B\$2:\$B\$5, 0),1000000000), IFERROR(MATCH("*"&\$A2&"*", \$C\$2:\$C\$5, 0), 1000000000))), "")