Match comma delimited values in a cell against individual values in a column

PeteSmith

New Member
Joined
Jan 9, 2010
Messages
23
Hi,

I would like to compare a list of values in column B against a list of values on every row in column M contained within a single comma delimited cell. There are somewhere in the region of 3000 rows so i want to avoid manually transposing a row at a time to find duplicates.

What i'm looking to do is match each of the comma delimited values in column M against the individual values on every row in column B.

For every row where all values in Column M are matched against values in column B i want a to return a TRUE value in column O. If any values are not found in column B i want to return a FALSE value in column O.

Colum BColumn MColumn O
PeterPeter, David, ClaireFALSE
DavidPaul, Peter, David, Claire, ThomasTRUE
PaulThomasFALSE
ThomasThomas, Claire, PeterFALSE
ClairePeterFALSE

<TBODY>
</TBODY>


Any help very much appreciated.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi,

I would like to compare a list of values in column B against a list of values on every row in column M contained within a single comma delimited cell. There are somewhere in the region of 3000 rows so i want to avoid manually transposing a row at a time to find duplicates.

What i'm looking to do is match each of the comma delimited values in column M against the individual values on every row in column B.

For every row where all values in Column M are matched against values in column B i want a to return a TRUE value in column O. If any values are not found in column B i want to return a FALSE value in column O.

Colum BColumn MColumn O
PeterPeter, David, ClaireFALSE
DavidPaul, Peter, David, Claire, ThomasTRUE
PaulThomasFALSE
ThomasThomas, Claire, PeterFALSE
ClairePeterFALSE

<tbody>
</tbody>


Any help very much appreciated.
Could you be clearer about your rules for determining true or false? Maybe I'm missing something but I can't pick up on your logic.

Are you suggesting for instance that in order to have TRUE in columnO and there are 3000 rows, then you must have 3000 matching comma separated values in columnM??
 
Upvote 0
The previous table i posted was completely wrong and didn't match the description. Apologies, here is a better representation of my data.

Column BColumn MColumn O
PeterPeter, David, Paul, SarahFALSE
DavidPaul, Peter, David, Claire, ThomasTRUE
PaulThomasTRUE
ThomasThomas, Claire, PeterTRUE
ClairePeterTRUE
MandySuzan, Thomas, PaulFALSE

<TBODY>
</TBODY>

Column O is false on rows 2 & 7 as neither Sarah or Suzan appear anywhere in column B but do appear in column M in the comma delimited cell.
 
Upvote 0
The previous table i posted was completely wrong and didn't match the description. Apologies, here is a better representation of my data.

Column BColumn MColumn O
PeterPeter, David, Paul, SarahFALSE
DavidPaul, Peter, David, Claire, ThomasTRUE
PaulThomasTRUE
ThomasThomas, Claire, PeterTRUE
ClairePeterTRUE
MandySuzan, Thomas, PaulFALSE

<tbody>
</tbody>

Column O is false on rows 2 & 7 as neither Sarah or Suzan appear anywhere in column B but do appear in column M in the comma delimited cell.
Hi Pete,

If you'd like to try a macro, then will this do it?
Code:
Sub matchups()
Dim d As Object, c, b() As Boolean
Dim k As Long, q, flg As Byte
Set d = CreateObject("scripting.dictionary")
For Each c In Range("B1", Cells(Rows.Count, "B").End(3)).Value
    d(c) = 1
Next c
For Each c In Range("M2", Cells(Rows.Count, "M").End(3)).Value
    k = k + 1: flg = 0
    ReDim Preserve b(1 To k)
    For Each q In Split(c, ",")
        If d(Trim(q)) <> 1 Then flg = 1: Exit For
    Next q
    If flg = 0 Then b(k) = 1
Next c
Range("O2").Resize(k) = Application.Transpose(b)
End Sub
Did you want your names in bold marked that way by the macro as well?
 
Upvote 0
That's fantastic, works a treat. And yes if it's easy enough to mark the names in bold that would be the icing on the cake!
 
Upvote 0
Hi Pete

If you wanted to consider a formula option, here's one that should work (it definitely won't bold the missing name, however!):


Excel 2010
BMNOP
1Column BColumn MColumn O
2PeterPeter, David, Paul,SarahFALSEFALSE
3DavidPaul, Peter, David, Claire, ThomasTRUETRUE
4PaulThomasTRUETRUE
5ThomasThomas, Claire, PeterTRUETRUE
6ClairePeterTRUETRUE
7MandySuzan, Thomas, PaulFALSEFALSE
Sheet1
Cell Formulas
RangeFormula
P2{=COUNT(MATCH(TRIM(MID(SUBSTITUTE(M2,",",REPT(" ",100)),(Num_Array-1)*100+1,100)),$B$2:$B$7,0))=(LEN(M2)-LEN(SUBSTITUTE(M2,",",""))+1)}
Press CTRL+SHIFT+ENTER to enter array formulas.
Named Ranges
NameRefers ToCells
Num_Array=ROW(INDIRECT("1:255"))
 
Upvote 0
That's fantastic, works a treat. And yes if it's easy enough to mark the names in bold that would be the icing on the cake!
Thanx for the feedback. Good that it worked OK.

To bold the first of the "false" strings in a columnM cell, try this
Code:
Sub matchups2()
Dim d As Object, c, b() As Boolean
Dim k As Long, q, flg As Byte, s As Range
Set d = CreateObject("scripting.dictionary")
For Each c In Range("B1", Cells(Rows.Count, "B").End(3)).Value
    d(c) = 1
Next c
For Each c In Range("M2", Cells(Rows.Count, "M").End(3)).Value
    k = k + 1: flg = 0
    ReDim Preserve b(1 To k)
    For Each q In Split(c, ",")
        If d(Trim(q)) <> 1 Then
            flg = 1
            Set s = Cells(k + 1, "m")
            s.Characters(InStr(s, q), Len(q)).Font.Bold = True
            Exit For
        End If
    Next q
    If flg = 0 Then b(k) = 1
Next c
Range("O2").Resize(k) = Application.Transpose(b)
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,892
Messages
6,127,613
Members
449,390
Latest member
joan12

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