This is doable, but requires the use of VBA to accomplish in a single step.
To use VBA, copy the code below, go to Excel, hit Alt+F11, go to Insert -> Module, and paste the code in the window that pops up. Close that window.
Now you have a new function called ConcatIf.
Its useage: ConcatIf(criteria range, criteria, return range, optional delimiter in quotes)
So in B14: =ConcatIf($A$2:$A$10,A14,$B$2:$B$10,CHAR(10))
Note, I used the delimiter Char(10) which is code for "the next line" which is what it'll input between cells it pulls together. To make sure it appears normal, you'll need to turn on Wrap Text for the cell.
See attached for clarification
Function ConcatIf(ByVal compareRange As Range, ByVal xCriteria As Variant, Optional ByVal stringsRange As Range, _
Optional Delimiter As String, Optional NoDuplicates As Boolean) As String
'code written by someone smarter than me
'useage: ConcatIf(criteria range, criteria, return range, optional delimiter in quotes)
'the Delimiter and NoDuplicates arguments are optional (default "" and False)
Dim i As Long, j As Long
With compareRange.Parent
Set compareRange = Application.Intersect(compareRange, Range(.UsedRange, .Range("a1")))
End With
If compareRange Is Nothing Then Exit Function
If stringsRange Is Nothing Then Set stringsRange = compareRange
Set stringsRange = compareRange.Offset(stringsRange.Row - compareRange.Row, _
stringsRange.Column - compareRange.Column)
For i = 1 To compareRange.Rows.Count
For j = 1 To compareRange.Columns.Count
If (Application.CountIf(compareRange.Cells(i, j), xCriteria) = 1) Then
If InStr(ConcatIf, Delimiter & CStr(stringsRange.Cells(i, j))) <> 0 Imp Not (NoDuplicates) Then
ConcatIf = ConcatIf & Delimiter & CStr(stringsRange.Cells(i, j))
End If
End If
Next j
Next i
ConcatIf = Mid(ConcatIf, Len(Delimiter) + 1)
End Function
Bookmarks