# lookup partial strings

#### Tigerexcel

##### Active Member
Am trying to get the spreadsheet to return the number of times a partial string is contained in a word depending on which list the substrings come from. The desired output is in Column C. The first record Seinfeld contains ei and thus returns 1 only. I imagine this might require an Array function but any Excel function deemed appropriate will do.

 Word List Answer List A ei ot an sk gh Seinfeld List A 1 List B er ee ef ow ev Fred Evans List B 1 List C op ck at ei it Mary Ansky List A 2 Cate List C 1 Acer List B 1 Show tee List B 2 Janet List A 1 Carrot List A 1 Opat List C 2 Skylight List A 2

### Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

#### ngoctinh87

##### New Member
Am trying to get the spreadsheet to return the number of times a partial string is contained in a word depending on which list the substrings come from. The desired output is in Column C. The first record Seinfeld contains ei and thus returns 1 only. I imagine this might require an Array function but any Excel function deemed appropriate will do.

 Word List Answer List A ei ot an sk gh Seinfeld List A 1 List B er ee ef ow ev Fred Evans List B 1 List C op ck at ei it Mary Ansky List A 2 Cate List C 1 Acer List B 1 Show tee List B 2 Janet List A 1 Carrot List A 1 Opat List C 2 Skylight List A 2
Try
VBA Code:
``C2=SUMPRODUCT(--ISNUMBER(SEARCH(INDEX(\$F\$1:\$J\$3,MATCH(B2,\$E\$1:\$E\$3,),),A2)))``

#### Tigerexcel

##### Active Member
Thanks Ngoc, it works. I'm having a little trouble understanding a part of it. I step through the formula with F9 and the INDEX(\$F\$1:\$J\$3,MATCH(B2,\$E\$1:\$E\$3,),) part gives me an error #REF. Is this because it's trying to return an array.

I've got another question as well for anyone who wants to chime in, as I was waiting for a response to this thread, my attempt at producing a solution to this was:

=SUMPRODUCT((\$G\$1:\$G\$3=B2)*(ISNUMBER(SEARCH(\$H\$1:\$L\$3,A2)))) which seems to work ok but I'm not sure how it adjusts for the different list option ie how does it adjust for List A compared to B unless the G1:G3=B2 creates a single row array that multiplies by another single row array. How does it remove the unwanted entries from H1:L3?

#### Fluff

##### MrExcel MVP, Moderator
When posting data to the board it's best to use the "Generate output" button, rather than the "Table only", that we we can see where your data is located.
I suspect that you get the error because your data does not start in A1.

+Fluff New.xlsm
ABCDEFGHIJ
2SeinfeldList A1List Bereeefowev
3Fred EvansList B1List Copckateiit
4Mary AnskyList A2
5CateList C1
6AcerList B1
7Show teeList B2
8JanetList A1
9CarrotList A1
10OpatList C2
11SkylightList A2
Sheet2
Cell Formulas
RangeFormula
C2:C11C2=SUMPRODUCT(--ISNUMBER(SEARCH(INDEX(\$F\$1:\$J\$3,MATCH(B2,\$E\$1:\$E\$3,),),A2)))

#### Tigerexcel

##### Active Member
Thanks Fluff for the feedback and I'll use the Generate output option. So this leaves one more question:

=SUMPRODUCT((\$G\$1:\$G\$3=B2)*(ISNUMBER(SEARCH(\$H\$1:\$L\$3,A2)))) which seems to work ok but I'm not sure how it adjusts for the different list option ie how does it adjust for List A compared to B unless the G1:G3=B2 creates a single row array that multiplies by another single row array. How does it remove the unwanted entries from H1:L3?

At this stage the above formula seems to work and indicates that you can achieve results with different formulae, just got to get my head around these array calculations.

#### Fluff

##### MrExcel MVP, Moderator
Best way to "see" what a formula is doing is to use the Evaluate formula button on the formula tab.

Replies
5
Views
165
Replies
3
Views
346
Replies
17
Views
503
Replies
2
Views
248
Replies
12
Views
1K

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,163,651
Messages
5,832,917
Members
430,175
Latest member
Sheenamarie

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