Formula that can compare cells and return results for partial matches

Monty85

Board Regular
Joined
May 6, 2019
Messages
53
Office Version
  1. 365
Platform
  1. Windows
Can anyone point in the right direction for a formula that can compare two cells and return a result for a partial match?

For example, I need to compare a list of names where one column may or may not contain a middle name. I.e;

A1 = John Smith
B1 = John F. Smith

I need a way to reference A1 and return a "True" result if the content of A1 is found somewhere in B1.

Appreciate any and all ideas.
 
Book1
ABC
1John SmithJohn F. SmithTRUE
2John SmithJohn SmithTRUE
3John SmithJohn SmithsFALSE
Sheet1
Cell Formulas
RangeFormula
C1:C3C1=OR(A1=B1,COUNTIF(B1,SUBSTITUTE(A1," "," * ")))
Had a quick test and this seems to do the job as well.

Thanks so much people - life savers.
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Book1
ABC
1John SmithJohn F. SmithTRUE
2John SmithJohn SmithTRUE
3John SmithJohn SmithsFALSE
Sheet1
Cell Formulas
RangeFormula
C1:C3C1=OR(A1=B1,COUNTIF(B1,SUBSTITUTE(A1," "," * ")))
Just on this again - how would I make the formula work the other way as well.

So both the below examples should return TRUE

MERCER_BT_AUS_PEP_03042023 - Validations (less formulas).xlsx
ABC
1John Fred SmithJohn SmithFALSE
2John SmithJohn Fred SmithTRUE
Sheet2
Cell Formulas
RangeFormula
C1:C2C1=OR(A1=B1,COUNTIF(B1,SUBSTITUTE(A1," "," * ")))
 
Upvote 0
Simply include the option inside OR():

Book1
ABC
1John Fred SmithJohn SmithTRUE
2John SmithJohn Fred SmithTRUE
Sheet2
Cell Formulas
RangeFormula
C1:C2C1=OR(A1=B1,COUNTIF(B1,SUBSTITUTE(A1," "," * ")),COUNTIF(A1,SUBSTITUTE(B1," "," * ")))
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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