How to ***** if a list of comma separated text values is a subset of another list of comma separated text values

jahmaira

New Member
Joined
Jun 18, 2016
Messages
4
Hello!

This is my first question, I hope someone can help me and I hope I will be clear in explaining myself.

So I have two columns , A and B, in each row I have a list of text values separated by ",". What I would like to know is whether all the elements present in B are also present in A.

It will be brilliant to have something similar to: IF(ISNUMBER(SEARCH(B1;A1));1;0) but instead of having a single value to look for in B1 I have a list. I cannot use {("item1","item2","item3")} because the list of elements in both A and B change for every row.

here an example of my data set:


ABC
AP,HU,SU,WIAP,HU1
BE,ZD,ZO,AP,HU
BE,ZO,ZD1
IR,OL,WI,MA,CAIR,OL,NI,GW0
EM,SU,AP,HUEM,SU,MA,CA,AP,HU0

<tbody>
</tbody>

I'm using excel for mac 2011

Thank you very much in advance to anyone who will take time to help me :D
 
I can't think of a formula based solution, but for VBA, this UDF and the formula =RemoveSubStrings(B1, A1, ",")

Code:
Function RemoveSubStrings(aString As String, DelimitedSubStrings As String, Optional Delimiter As String = " ") As String
    Dim oneSubString As Variant
    
    RemoveSubStrings = Delimiter & aString & Delimiter
    
    For Each oneSubString In Split(Delimiter & DelimitedSubStrings & Delimiter, Delimiter)
        RemoveSubStrings = Replace(RemoveSubStrings, Delimiter & oneSubString & Delimiter, Delimiter)
    Next oneSubString
    
    RemoveSubStrings = Left(RemoveSubStrings, Len(RemoveSubStrings) - Len(Delimiter))
    RemoveSubStrings = Mid(RemoveSubStrings, Len(Delimiter) + 1)
End Function
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,215,482
Messages
6,125,061
Members
449,206
Latest member
Healthydogs

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