Use a lookup to find conditional values in multiple rows and concatenate the results

TheBoogExcelQs

New Member
Joined
Sep 30, 2014
Messages
4
I have a spreadsheet that lists gifts on a registry in one column. In another column, are potential names of the folks that bought the items.

What i'd like to do is, use a lookup formula of some sort to find all the instances of a name (ex. "John Doe") and then combine all of the registry items they purchased into another cell. I'd like the name finder to be variable so I can use it down a list of guests.

Is this possible to do in excel?
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi, see solution by Aladin Akyurek in the thread

<title>Excel Jeanie HTML</title>Sheet2

ABCDE
1GiftName Jhon DoeDoe
2Coffe TableJhon Doe 31
3PenJhon Doe
4PencilDoe
5WatchJhon Doe Gift ItemGift Item
6 Coffe TablePencil
7 Pen
8 Watch

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:78px;"><col style="width:64px;"><col style="width:64px;"><col style="width:75px;"><col style="width:64px;"></colgroup><tbody>
</tbody>

Formeln der Tabelle
ZelleFormel
D2=COUNTIF($B$2:$B$5,D$1)
E2=COUNTIF($B$2:$B$5,E$1)
D6{=IF(ROWS($D$5:D5)<=D$2,INDEX($A$2:$A$5,IF(D$2>1,SMALL(IF($B$2:$B$5=D$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:D5)),MATCH(D$1,$B2:$B$5,0))),"")}
E6{=IF(ROWS($D$5:E5)<=E$2,INDEX($A$2:$A$5,IF(E$2>1,SMALL(IF($B$2:$B$5=E$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:E5)),MATCH(E$1,$B2:$B$5,0))),"")}
D7{=IF(ROWS($D$5:D6)<=D$2,INDEX($A$2:$A$5,IF(D$2>1,SMALL(IF($B$2:$B$5=D$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:D6)),MATCH(D$1,$B3:$B$5,0))),"")}
E7{=IF(ROWS($D$5:E6)<=E$2,INDEX($A$2:$A$5,IF(E$2>1,SMALL(IF($B$2:$B$5=E$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:E6)),MATCH(E$1,$B3:$B$5,0))),"")}
D8{=IF(ROWS($D$5:D7)<=D$2,INDEX($A$2:$A$5,IF(D$2>1,SMALL(IF($B$2:$B$5=D$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:D7)),MATCH(D$1,$B4:$B$5,0))),"")}
E8{=IF(ROWS($D$5:E7)<=E$2,INDEX($A$2:$A$5,IF(E$2>1,SMALL(IF($B$2:$B$5=E$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:E7)),MATCH(E$1,$B4:$B$5,0))),"")}

<tbody>
</tbody>
Enthält Matrixformel:
Umrandende
{ } nicht miteingeben,
sondern Formel mit STRG+SHIFT+RETURN abschließen!
Matrix verstehen

<tbody>
</tbody>


Excel Tabellen im Web darstellen >> Excel Jeanie HTML 4.8
 
Last edited:
Upvote 0
Hi, thank you. Close, but I'm looking for something more like:

Sheet2


ABCDE
1GiftNameJhon DoeCoffe Table, Pen, Watch
2Coffe TableJhon DoeDoePencil
3PenJhon Doe
4PencilDoe
5WatchJhon Doe

<tbody>
</tbody>

Any ideas?

Hi, see solution by Aladin Akyurek in the thread

<title>Excel Jeanie HTML</title>Sheet2

ABCDE
1GiftNameJhon DoeDoe
2Coffe TableJhon Doe31
3PenJhon Doe
4PencilDoe
5WatchJhon DoeGift ItemGift Item
6Coffe TablePencil
7Pen
8Watch

<tbody>
</tbody>

Formeln der Tabelle
ZelleFormel
D2=COUNTIF($B$2:$B$5,D$1)
E2=COUNTIF($B$2:$B$5,E$1)
D6{=IF(ROWS($D$5:D5)<=D$2,INDEX($A$2:$A$5,IF(D$2>1,SMALL(IF($B$2:$B$5=D$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:D5)),MATCH(D$1,$B2:$B$5,0))),"")}
E6{=IF(ROWS($D$5:E5)<=E$2,INDEX($A$2:$A$5,IF(E$2>1,SMALL(IF($B$2:$B$5=E$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:E5)),MATCH(E$1,$B2:$B$5,0))),"")}
D7{=IF(ROWS($D$5:D6)<=D$2,INDEX($A$2:$A$5,IF(D$2>1,SMALL(IF($B$2:$B$5=D$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:D6)),MATCH(D$1,$B3:$B$5,0))),"")}
E7{=IF(ROWS($D$5:E6)<=E$2,INDEX($A$2:$A$5,IF(E$2>1,SMALL(IF($B$2:$B$5=E$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:E6)),MATCH(E$1,$B3:$B$5,0))),"")}
D8{=IF(ROWS($D$5:D7)<=D$2,INDEX($A$2:$A$5,IF(D$2>1,SMALL(IF($B$2:$B$5=D$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:D7)),MATCH(D$1,$B4:$B$5,0))),"")}
E8{=IF(ROWS($D$5:E7)<=E$2,INDEX($A$2:$A$5,IF(E$2>1,SMALL(IF($B$2:$B$5=E$1,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($D$5:E7)),MATCH(E$1,$B4:$B$5,0))),"")}

<tbody>
</tbody>
Enthält Matrixformel:
Umrandende
{ } nicht miteingeben,
sondern Formel mit STRG+SHIFT+RETURN abschließen!
Matrix verstehen

<tbody>
</tbody>


Excel Tabellen im Web darstellen >> Excel Jeanie HTML 4.8
 
Upvote 0
I guess my question boils down to:

In Excel, can you concatenate multiple cells (in a column) based on meeting a single conditional argument?
 
Upvote 0
I guess my question boils down to:

In Excel, can you concatenate multiple cells (in a column) based on meeting a single conditional argument?

Not without VBA, no. (Or else unfeasibly long formula constructions.)

Regards
 
Upvote 0
I'm afraid my VBA is quite poor, but give this a go:

Code:
Sub Concat1()

Dim SearchNames As Range, SourceNames As Range

Set SearchNames = Range("D1:D" & Cells(Rows.Count, "D").End(xlUp).Row)
Set SourceNames = Range("B2:B" & Cells(Rows.Count, "B").End(xlUp).Row)

On Error Resume Next

For Each r In SearchNames
    For Each s In SourceNames
        If s.Value = r.Value Then
            r.Offset(0, 1).Value = s.Offset(0, -1).Value & ", " & r.Offset(0, 1).Value
        End If
    Next s    
    r.Offset(0, 1).Value = Left(r.Offset(0, 1).Value, Len(r.Offset(0, 1).Value) - 2)
Next r

End Sub

Regards
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,925
Members
449,195
Latest member
Stevenciu

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