Comparing 2 cells for a partial much but need to ignore cells that are blank

ctucker

New Member
Joined
Jan 18, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I am using the following formulas to compare 2 cells for a partial match. The problem is, some of the cells are blank and it causes it to show up as a partial match.

Is there a way to compare 2 cells for a partial match that prevents blank cells showing up as a partial match?

Column E =IF(COUNTIF(D2,"*" & B2 & "*"),"Found match","No match")
Column F =IF(COUNTIF(D2,"*" & C2 & "*"),"Found match","No match")


B C D E F
HBO00Found matchFound match
000073Found matchFound match
AIXYACA11,AID03Found matchNo match
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi and welcome to MrExcel!

Try:

=IF(B2="","",IF(COUNTIF(D2,"*" & B2 & "*"),"Found match","No match"))

=IF(C2="","",IF(COUNTIF(D2,"*" & C2 & "*"),"Found match","No match"))
 
Upvote 1
Solution
Welcome to the board. You could do something like this and check B2/C2 for blanks and purposely return a string you know won't match anything:

Edit: Or use Dante's solution which will return a blank result if B2/C2 are blank, instead of "No Match".

Book1 1-18-2024.xlsm
ABCDEF
1
2HBO00No matchNo match
3000073No matchNo match
4AIXYACA11,AID03Found matchNo match
Sheet5
Cell Formulas
RangeFormula
E2:E4E2=IF(COUNTIF(D2,"*" & IF(B2="","BLANK",B2) & "*"),"Found match","No match")
F2:F4F2=IF(COUNTIF(D2,"*" & IF(C2="","BLANK",C2) & "*"),"Found match","No match")
 
Upvote 1
Welcome to the board. You could do something like this and check B2/C2 for blanks and purposely return a string you know won't match anything:

Edit: Or use Dante's solution which will return a blank result if B2/C2 are blank, instead of "No Match".

Book1 1-18-2024.xlsm
ABCDEF
1
2HBO00No matchNo match
3000073No matchNo match
4AIXYACA11,AID03Found matchNo match
Sheet5
Cell Formulas
RangeFormula
E2:E4E2=IF(COUNTIF(D2,"*" & IF(B2="","BLANK",B2) & "*"),"Found match","No match")
F2:F4F2=IF(COUNTIF(D2,"*" & IF(C2="","BLANK",C2) & "*"),"Found match","No match")
That was my next question. Thanks!
 
Upvote 0
Welcome to the board. You could do something like this and check B2/C2 for blanks and purposely return a string you know won't match anything:

Edit: Or use Dante's solution which will return a blank result if B2/C2 are blank, instead of "No Match".

Book1 1-18-2024.xlsm
ABCDEF
1
2HBO00No matchNo match
3000073No matchNo match
4AIXYACA11,AID03Found matchNo match
Sheet5
Cell Formulas
RangeFormula
E2:E4E2=IF(COUNTIF(D2,"*" & IF(B2="","BLANK",B2) & "*"),"Found match","No match")
F2:F4F2=IF(COUNTIF(D2,"*" & IF(C2="","BLANK",C2) & "*"),"Found match","No match")

Welcome to the board. You could do something like this and check B2/C2 for blanks and purposely return a string you know won't match anything:

Edit: Or use Dante's solution which will return a blank result if B2/C2 are blank, instead of "No Match".

Book1 1-18-2024.xlsm
ABCDEF
1
2HBO00No matchNo match
3000073No matchNo match
4AIXYACA11,AID03Found matchNo match
Sheet5
Cell Formulas
RangeFormula
E2:E4E2=IF(COUNTIF(D2,"*" & IF(B2="","BLANK",B2) & "*"),"Found match","No match")
F2:F4F2=IF(COUNTIF(D2,"*" & IF(C2="","BLANK",C2) & "*"),"Found match","No match")
Thanks! It worked great
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top