I have a list of companies such as :
COCA
COCA COLA
SPRITE
An other list of companies is given, more detailled.
Is the cell a substring of at least one element of the list ?
COCA COLA USA TRUE
PEPSI FALSE
SPIRIT FALSE
I have tried with approximate match but the result is wrong. I would like something like this :
=EQUIV([@Company_long_name];"*"&Table[Company]&"*";0)
Thanks for reading
In VBA you could do something like this:
Sub findIfSubString()
Dim ws1, ws2 As Worksheet
Set ws1 = Worksheets("Tabelle1")
Set ws2 = Worksheets("Tabelle2")
i = 1
Do While ws1.Cells(i, 1) <> ""
j = 1
ws2.Cells(i, 2) = "FALSE"
Do While ws2.Cells(j, 1) <> ""
If InStr(ws2.Cells(i, 1), ws1.Cells(i, 1)) Then
ws2.Cells(i, 2) = "TRUE"
Exit Do
Else
j = j + 1
End If
Loop
i = i + 1
Loop
End Sub
Change your code accordingly to your format. From your example, "COCA", "COCA COLA" and "SPRITE" would be in column 1 of ws1
and both other set would be in columns 1 and 2 of ws2
EDIT: Code looks now for possible in string-matches for all entries.
more than one way to do this, pick the one you are more comfortable with
method 1 formula
=SUM(IFERROR(MATCH("*"&($A$2:$A$4)&"*",$B2,0),0))>0
method 2 formula
=LARGE(COUNTIF(B2,"*"&$A$2:$A$4&"*"),1)>0
Note: this is array formula. it is not single array formula but seprate array for each cell. so first put formula into single cell (start at row 2 for my formula), then CTRL+D to to fill down.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.