lookup partial strings

Tigerexcel

Active Member
Joined
Mar 6, 2020
Messages
493
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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.

WordListAnswerList Aeiotanskgh
SeinfeldList A1List Bereeefowev
Fred EvansList B1List Copckateiit
Mary AnskyList A2
CateList C1
AcerList B1
Show teeList B2
JanetList A1
CarrotList A1
OpatList C2
SkylightList A2
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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.

WordListAnswerList Aeiotanskgh
SeinfeldList A1List Bereeefowev
Fred EvansList B1List Copckateiit
Mary AnskyList A2
CateList C1
AcerList B1
Show teeList B2
JanetList A1
CarrotList A1
OpatList C2
SkylightList A2
Try
VBA Code:
C2=SUMPRODUCT(--ISNUMBER(SEARCH(INDEX($F$1:$J$3,MATCH(B2,$E$1:$E$3,),),A2)))
 
Upvote 0
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?
 
Upvote 0
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
1WordListAnswerList Aeiotanskgh
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)))
 
Upvote 0
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.
 
Upvote 0
Best way to "see" what a formula is doing is to use the Evaluate formula button on the formula tab.
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,573
Members
449,089
Latest member
Motoracer88

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