Cell with comma seperated values and vlookup

chrisnilu

New Member
Joined
Aug 8, 2017
Messages
8
1st table/report has cells with single values as well as multiple values separated by comma.

Identifier
AA
XY,AA,YX
BE
RE,WX,EW,XT
AB,ER,

<tbody>
</tbody>


if any of the values in the cell is there in the 2nd table I need to filter the 1st report.

2nd table/report
Identifier
WR
AA
XY
BE

<tbody>
</tbody>

As BE & AA are available in the 2nd table, 1st report should be filtered and should show only the 1st 3 rows (table values with BE & AA )

If the 1st report/table only has single values in a cell I can do a vlookup but as this has comma separated values how should I approach this ?

seeking for immediate assistance as I would need this for my work tomorrow. THANKS
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Use the autofilter.
Unselect all
Filter for each item on the second table by typing them in one at a time
The first time any rows are returned accept that filter.
The second and subsequent times rows are returned, choose the option "Add current selection to filter each time"
The lines from table 1 that contain any of the items entered will be displayed.
 
Last edited:
Upvote 0
If the 1st report/table only has single values in a cell I can do a vlookup but as this has comma separated values how should I approach this ?

Hi, another option you could try:


Excel 2013/2016
ABCD
1IdentifierFilter ?Table 2
2AATRUEWR
3XY,AA,YXTRUEAA
4BETRUEXY
5RE,WX,EW,XTFALSEBE
6AB,ER,FALSE
Sheet1
Cell Formulas
RangeFormula
B2=ISNUMBER(LOOKUP(1,-SEARCH(","&$D$2:$D$5&",",","&A2&",")))
 
Upvote 0
Unfortunately both the tables has thousands of records :(
What is the maximum number of rows for Table 1 (don't really need to know the number for the second table for the method I am thinking about)?

Are your tables real Excel Table objects or just groups of cells that you think of as tables?

Where are the tables located at?
 
Upvote 0
Maybe Advanced Filter + a formula

Something like

A
B
C
D
E
1
Identifier​
Identifier​
2
AA​
WR​
TRUE​
3
XY,AA,YX​
AA​
4
BE​
XY​
5
RE,WX,EW,XT​
BE​
6
AB,ER,​
7

Leave E1 blank

Formula in E2
=SUMPRODUCT(--ISNUMBER(SEARCH(C$2:C$5,A2)))>0

Select A1:A6 and apply Advanced Filter with Criteria Range=$E$1:$E$2

Hope this helps

M.
 
Upvote 0
Maybe Advanced Filter + a formula
Hi Marcelo
I also considered Adv Filter but the OP says thousands of rows in both tables and, for me at least, that made Adv Filter painfully slow.

Also, just noting with your formula that the OP would need to confirm that all individual Identifiers are exactly 2 characters long. Otherwise a formula like FormR's would be required.
 
Upvote 0
Hi Peter,

You are right, with thousands of rows in both tables adv filter should not be used - bad performance.
Maybe a macro using variant arrays...

M.
 
Upvote 0
Maybe a macro using variant arrays...
I have no idea how fast this will be given the number of rows involved, but possibly this macro (the layout info is set in the four highlighted Const statements)...
Code:
[table="width: 500"]
[tr]
	[td]Sub FilterIndentifiers()
  Dim R As Long, UnusedCol As Long, Table2 As Variant
  
[B][COLOR="#FF0000"]  Const Table1SheetName = "Sheet1"
  Const Table2SheetName = "Sheet2"
  Const Table1Col = "A"
  Const Table2Col = "A"
[/COLOR][/B]  
  With Sheets(Table2SheetName)
    Table2 = .Range(.Cells(2, Table2Col), .Cells(Rows.Count, Table2Col).End(xlUp))
  End With
  Application.ScreenUpdating = False
  With Sheets(Table1SheetName)
    UnusedCol = .Cells.Find("*", , xlFormulas, , xlByColumns, xlPrevious).Column + 1
    .AutoFilterMode = False
    .Rows.Hidden = False
    With .Range(.Cells(1, Table1Col), .Cells(Rows.Count, Table1Col).End(xlUp))
      For R = 1 To UBound(Table2)
        .AutoFilter 1, "*" & Table2(R, 1) & "*"
        Intersect(.SpecialCells(xlVisible).EntireRow, .Columns(UnusedCol)).Value = "X"
      Next
      .Parent.AutoFilterMode = False
      .Columns(UnusedCol).SpecialCells(xlBlanks).EntireRow.Hidden = True
      .Columns(UnusedCol).Clear
    End With
  End With
  Application.ScreenUpdating = True
End Sub[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
this looks simple but in my case I have to do the filtering in Column A if the same value is there in Column C ( cannot do it the other way due to the nature of data ) . Column A cells might have single or multiple values and Column C will always have single values.
 
Upvote 0

Forum statistics

Threads
1,214,381
Messages
6,119,192
Members
448,874
Latest member
Lancelots

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