Pull List From Multiple Columns

downwithjunk

New Member
Joined
May 30, 2013
Messages
16
I'm trying to pull a dataset from a bulk set based on a cell value. I usually do this with an index match; however, now I'm needing to get it based out of multiple columns which I'm not able to figure out. Below is a sample of the setup. I would like to have a dynamic list (A12:B14) based on the value in A9. But it would need to include if Apples appears in column C, D, or E. Any help would be greatly appreciated.

ABCDE
1FIRSTLASTTAG1TAG2TAG3
2BillSmithApples
3ToddBlackOranges
4BrettHarrisPearsApples
5MaryWhitePearsOrangesGrapes
6JacobGreenGrapesPearsApples
7
8PRODUCT
9Apples
10
11LIST
12BillSmith
13BrettHarris
14JacobGreen
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
If you don't mind using vba, here is a macro that will create the list. the code assumes you would want to remove existing list, if any and create a new one based on criteria.
VBA Code:
Sub t()
Dim fn As Range, crt As Variant, adr As String
With ActiveSheet
    .Range("A12:B12", .Range("A12:B12").End(xlDown)).ClearContents
    crt = .Range("A9").Value
    Set fn = Intersect(.UsedRange, .Range("C:E")).Find(crt, , xlValues, xlWhole)
        If Not fn Is Nothing Then
            adr = fn.Address
            Do
                If Range("A12") = "" Then
                    .Cells(fn.Row, 1).Resize(, 2).Copy .Range("A12")
                Else
                    .Cells(fn.Row, 1).Resize(, 2).Copy .Cells(Rows.Count, 1).End(xlUp)(2)
                End If
                Set fn = Intersect(.UsedRange, .Range("C:E")).FindNext(fn)
            Loop While fn.Address <> adr
        End If
End With
End Sub
Run the code from the standard code module1.
 
Upvote 0
  1. I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

  2. Also have a look at XL2BB as a better way to post your sample data and expected results.

I'm trying to stick with a formula if at all possible.
Can we use a helper column (which could be hidden)?

Because of point 1 above I'm not sure which of these will be best for you.

If you have Excel 365 with the FILTER function then all you need is to put the formula shown into cell A12 only and the other results will automatically 'spill' into the other required cells.

downwithjunk 2020-04-16 1.xlsm
ABCDEF
1FIRSTLASTTAG1TAG2TAG3All Tags
2BillSmithApples|Apples|
3ToddBlackOranges|Oranges|
4BrettHarrisPearsApples|Pears|Apples|
5MaryWhitePearsOrangesGrapes|Pears|Oranges|Grapes|
6JacobGreenGrapesPearsApples|Grapes|Pears|Apples|
7
8PRODUCT
9Apples
10
11LIST
12BillSmith
13BrettHarris
14JacobGreen
15
Sheet1
Cell Formulas
RangeFormula
F2:F6F2="|"&TEXTJOIN("|",1,C2:E2)&"|"
A12:B14A12=FILTER(A2:B6,ISNUMBER(SEARCH("|"&A9&"|",F2:F6)))
Dynamic array formulas.



If you have Excel 2010 or later then try these formulas in row 12, copied down as far as you might need.

downwithjunk 2020-04-16 1.xlsm
ABCDEF
1FIRSTLASTTAG1TAG2TAG3All Tags
2BillSmithApples|Apples|
3ToddBlackOranges|Oranges|
4BrettHarrisPearsApples|Pears|Apples|
5MaryWhitePearsOrangesGrapes|Pears|Oranges|Grapes|
6JacobGreenGrapesPearsApples|Grapes|Pears|Apples|
7
8PRODUCT
9Apples
10
11LIST
12BillSmith
13BrettHarris
14JacobGreen
15  
16  
Sheet2
Cell Formulas
RangeFormula
F2:F6F2="|"&TEXTJOIN("|",1,C2:E2)&"|"
A12:A16A12=IFERROR(INDEX(A$2:A$6,AGGREGATE(15,6,(ROW(A$2:A$6)-ROW(A$2)+1)/ISNUMBER(SEARCH("|"&$A$9&"|",$F$2:$F$6)),ROWS(A$12:A12))),"")
B12:B16B12=IF(A12="","",INDEX(B$2:B$6,AGGREGATE(15,6,(ROW(B$2:B$6)-ROW(B$2)+1)/ISNUMBER(SEARCH("|"&$A$9&"|",$F$2:$F$6)),ROWS(A$12:A12))))
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,547
Members
449,089
Latest member
davidcom

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