Return for each cell in a range the portion matching a list of string

ED38

New Member
Joined
Mar 29, 2024
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to build a formula doing the following :
For each cell in the range T2:T38 containing a text string if it includes one of the sub-string listed in the range U2:U12 then show the matching sub-string in a spilled formula as show in column V :
I found a way to do it on ONE cell (my formula in Y2 but I would need a spilled version of a similar formula... ;) )

2024-08-29 SKU Report - Cat code Recommendation.xlsm
TUVWXY
1DataString to searchexpected resultsCommentmy Try but works only on a single cell not for the array from T2:T38
2ON_PREMISE_SUBSUBSUBSUB
3SAAS_WO_CONSSAASCONS
4EXTSUPP_PLUSSUPPSUPP
5ON_PREMISE_EVALEVALEVAL
6PS_PACKAGEDPSPS
7ON_PREMISE_PERPPERPPERP
8ELA_SUPPORT_SUMMARYOTHERSUPP
9ELA_LICENSE_SUMMARYCONSnothing
10FOUNDATION_SUPPORTHWSUPP
11ADVSUPP_WO_CONSEDUSUPPbecause SUPP appears before CONS
12ON_PREMISE_CONS_PPUTERMCONS
13SAAS_FLEXSAAS
14SAAS_PACKAGEDSAAS
15SAAS_W_CONSSAAS
16SAAS_EVALSAAS
17SAAS_BILL_ONLYSAAS
18INCIDENT_PACKnothing
19HW_SALESnothing
20PS_CUSTOMPS
21PS_TIME_AND_EXPENSESPS
22ON_PREMISE_BILL_ONLYnothing
23EDU_CUSTOMEDU
24ON_PREMISE_SUB_ACASUB
25EDU_SERVICES
26ON_PREMISE_TERM_FIXED
27ON_PREMISE_TERM
28CUSTOM_SUPPORT
29EDU_ONDEMAND_TRAINING
30ON_PREMISE_SUB_CONTENT
31EDU_TIME_AND_EXPENSE
32SUPP_BILL_ONLY
33ON_PREMISE_OPENS
34ON_PREMISE_LIC_EXT
35SAAS_CUSTOM
36SAAS_TIME_AND_EXPENSE
37CREDITS
38RTS
report1701769401652
Cell Formulas
RangeFormula
Y2Y2=@OFFSET($U$1,SUMPRODUCT((COUNTIF(T2,"*"&$U$2:$U$12&"*"))*(ROW(U2:U12)-ROW($U$2)+1)),0,,)


Thanks for any idea if you can help
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
How about
Fluff.xlsm
TUVW
1DataString to searchexpected results
2ON_PREMISE_SUBSUBSUBSUB
3SAAS_WO_CONSSAASSAASCONS
4EXTSUPP_PLUSSUPPSUPPSUPP
5ON_PREMISE_EVALEVALEVALEVAL
6PS_PACKAGEDPSPSPS
7ON_PREMISE_PERPPERPPERPPERP
8ELA_SUPPORT_SUMMARYOTHERSUPPSUPP
9ELA_LICENSE_SUMMARYCONS
10FOUNDATION_SUPPORTHWSUPPSUPP
11ADVSUPP_WO_CONSEDUSUPPSUPP
12ON_PREMISE_CONS_PPUTERMCONSCONS
13SAAS_FLEXSAASSAAS
14SAAS_PACKAGEDSAASSAAS
15SAAS_W_CONSSAASSAAS
16SAAS_EVALSAASSAAS
17SAAS_BILL_ONLYSAASSAAS
18INCIDENT_PACK
19HW_SALESHW
20PS_CUSTOMPSPS
21PS_TIME_AND_EXPENSESPSPS
22ON_PREMISE_BILL_ONLY
23EDU_CUSTOMEDUEDU
24ON_PREMISE_SUB_ACASUBSUB
25EDU_SERVICESEDU
26ON_PREMISE_TERM_FIXEDTERM
27ON_PREMISE_TERMTERM
28CUSTOM_SUPPORTSUPP
29EDU_ONDEMAND_TRAININGEDU
30ON_PREMISE_SUB_CONTENTSUB
31EDU_TIME_AND_EXPENSEEDU
32SUPP_BILL_ONLYSUPP
33ON_PREMISE_OPENS
34ON_PREMISE_LIC_EXT
35SAAS_CUSTOMSAAS
36SAAS_TIME_AND_EXPENSESAAS
37CREDITS
38RTS
Sheet6
Cell Formulas
RangeFormula
V2:V38V2=MAP(T2:T38,LAMBDA(m,TAKE(FILTER(U2:U12,ISNUMBER(SEARCH(U2:U12,m)),""),1)))
Dynamic array formulas.


Although I get different results from what you showed.
 
Upvote 0
Solution
A bit long formula (probably could be compacted with LET), but seems to return right results).

Excel Formula:
=IFERROR(TEXTSPLIT(BYROW(IF(LEN(T2:T38)-LEN(SUBSTITUTE(T2:T38,TRANSPOSE(U2:U12),""))>0,TRANSPOSE(U2:U12),""),LAMBDA(arr,TEXTJOIN(";",,arr))),";",",",TRUE),"")
 
Upvote 0
Thank again Fluff.
It's exactly what I expected
No worries for the different results, I will manage the details.
Very happy and lucky you care my requests.
you're my "excel guardian angel"!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
A bit long formula (probably could be compacted with LET), but seems to return right results).

Excel Formula:
=IFERROR(TEXTSPLIT(BYROW(IF(LEN(T2:T38)-LEN(SUBSTITUTE(T2:T38,TRANSPOSE(U2:U12),""))>0,TRANSPOSE(U2:U12),""),LAMBDA(arr,TEXTJOIN(";",,arr))),";",",",TRUE),"")
Thank you Kaper for your time as well (I was also looking for something using the "byrow" function ;) ). It seems like you did it
 
Upvote 0
In this instance both Map & Byrow do the same thing, so you could just swap Map for Byrow in the formula I supplied & it will return the same answers.
 
Upvote 0
In this instance both Map & Byrow do the same thing, so you could just swap Map for Byrow in the formula I supplied & it will return the same answers.
Good to know. Thank you again.
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

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