Concatenate with more than one logical test and multiple results

dl08in

New Member
Joined
Aug 6, 2015
Messages
2
I'm looking for a way to compare a text string or cell address to a column of possible matches. Then I want to concatenate notes from every row that has a match, but only if a logical test is true. A UDF would be perfect.

I've seen one from Rick Rothstein mentioned a couple times now, but I can't figure out how to add the logical test that I require. In the table below is an example of what I'm looking for. The values in column A (Item) are irrelevant for my purposes, but I want to compare their cell addresses (text strings) against a lookup table in D1:F7. Column B is an example of the results I'm looking for. Note that item $A$2 is present in D3, but the logical test in E3 returns FALSE so B2 is empty. $A$3 is present in D2 and D5. E2 is TRUE and E5 is FALSE, so only F2 is returned in B3. I hope this makes sense.

ABCDEF
1ItemResultsCell ReferencesLogical TestNotes
21$A$3, $A$5TRUEAA
32AA$A$2FALSEBB
43EE$A$6FALSECC
54AA$A$3FALSEDD
65EE$A$4, $A$6, $A$7TRUEEE
76EE, FF$A$7TRUEFF

<tbody>
</tbody>
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
B2: control+shift+enter, not just enter, and copy down:
Rich (BB code):

=REPLACE(ACONCAT(IF(ISNUMBER(SEARCH(CELL("address",A2),$D$2:$D$7)),
    IF($E$2:$E$7,", "&$F$2:$F$7,""),"")),1,2,"")
For this formula to work, you need to add ACONCAT as a module, using Alt+F1, to your workbook:

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function
 
Upvote 0
That works! I don't fully understand it, but it does exactly what I wanted. Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,004
Messages
6,122,659
Members
449,091
Latest member
peppernaut

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