# Compare two columns row by row, count substring matches

#### jokr1

##### New Member
I want to compare columns A and B, row by row, where values in B might contain substrings of A.
How can I count the number of substring matches ("am" in hamster, "bit" in rabbit, "us" in mouse and "squirrel" in squirrel) with a formula? (Do not want to use column C at all to indicate if each row is a match or not)

I guess I have to use countifs or sumproduct? But don't know how to do it in this specific case.

Last edited:

### Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},\$Z\$1:\$Z\$99,\$Y\$1:\$Y\$99),2,False) to lookup Y values to left of Z values.

#### Fluff

##### MrExcel MVP, Moderator
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

#### JoeMo

##### MrExcel MVP
Substitute SEARCH for FIND if you want to ignore case in your matches.
Book1
ABCD
1frogme
2hamsteram
3catematches
4rabbitbit4
5mouseus
6gorrilahey
7squirrelsquirrel
Sheet2 (2)
Cell Formulas
RangeFormula
D4D4=SUMPRODUCT(--ISNUMBER(FIND(\$B\$1:\$B\$7,\$A\$1:\$A\$7)))

#### jokr1

##### New Member
JoeMo, thanks! Used your search formula, works like a charm!

#### JoeMo

##### MrExcel MVP
JoeMo, thanks! Used your search formula, works like a charm!
You are welcome - thanks for the reply.

Replies
12
Views
929
Replies
8
Views
483
Replies
2
Views
255
Replies
1
Views
99
Replies
9
Views
154

1,148,160
Messages
5,745,123
Members
423,927
Latest member
Pra56

### 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.

### Which adblocker are you using?

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

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