Formula to concatenate with multiple if conditions

Manatarms

New Member
Joined
Oct 12, 2021
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
Hi can anyone help please, I am trying to create a formula that looks down a list of data and concatenates the names of two if conditions are met? So in the example of shop is A and region is North then concatenate names save and Mike. Thanks!
 

Attachments

  • 4490A1C8-BD61-4690-AC83-5E27A6D7E6D0.png
    4490A1C8-BD61-4690-AC83-5E27A6D7E6D0.png
    11 KB · Views: 24

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi can anyone help please, I am trying to create a formula that looks down a list of data and concatenates the names of two if conditions are met? So in the example of shop is A and region is North then concatenate names save and Mike. Thanks!
I cant test this as my version of excel doesnt have TEXTJOIN but I believe 2016 does.
Try putting this in your output cell. Its an ARRAY formula so will need to be entered with Ctrl+Shift+Enter
Excel Formula:
=TEXTJOIN(",",TRUE,IF(($A2:$A9="A")*($B2:$B9="North"),$C2:$C9,""))
 
Upvote 0
I cant test this as my version of excel doesnt have TEXTJOIN but I believe 2016 does.
But your profile shows you are using 2016. :unsure:
However 2016 doesn't have textjoin.
 
Upvote 0
But your profile shows you are using 2016. :unsure:
However 2016 doesn't have textjoin.
temporarily on a different machine, was sure i had used textjoin on my personal comp. guess it must have been on the works one. always happy to admit when wrong;)
 
Upvote 0
Hi,

This is Ugly, and Only works if there are no more than 2 matches.
If there are more than 2 matches, I would think a UDF or VBA solution is more suitable:

Book3.xlsx
ABCDEFGHI
1NorthSouth
2ANorthDaveADave,Mike 
3BSouthBobB Bob,Larry
4CNorthTonyCTony 
5DSouthGaryD Gary
6ENorthSteveESteve 
7FSouthTrevorF Trevor
8BSouthLarry
9ANorthMike
Sheet5
Cell Formulas
RangeFormula
H2:I7H2=SUBSTITUTE(TRIM(IFERROR(INDEX($C$2:$C$9,MATCH($G2&H$1,$A$2:$A$9&$B$2:$B$9,0)),"")&" "&IF(IFERROR(LOOKUP(2,1/SEARCH($G2&H$1,$A$2:$A$9&$B$2:$B$9),$C$2:$C$9),"")=IFERROR(INDEX($C$2:$C$9,MATCH($G2&H$1,$A$2:$A$9&$B$2:$B$9,0)),""),"",IFERROR(LOOKUP(2,1/SEARCH($G2&H$1,$A$2:$A$9&$B$2:$B$9),$C$2:$C$9),"")))," ",",")
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hi,

This is Ugly, and Only works if there are no more than 2 matches.
If there are more than 2 matches, I would think a UDF or VBA solution is more suitable:

Book3.xlsx
ABCDEFGHI
1NorthSouth
2ANorthDaveADave,Mike 
3BSouthBobB Bob,Larry
4CNorthTonyCTony 
5DSouthGaryD Gary
6ENorthSteveESteve 
7FSouthTrevorF Trevor
8BSouthLarry
9ANorthMike
Sheet5
Cell Formulas
RangeFormula
H2:I7H2=SUBSTITUTE(TRIM(IFERROR(INDEX($C$2:$C$9,MATCH($G2&H$1,$A$2:$A$9&$B$2:$B$9,0)),"")&" "&IF(IFERROR(LOOKUP(2,1/SEARCH($G2&H$1,$A$2:$A$9&$B$2:$B$9),$C$2:$C$9),"")=IFERROR(INDEX($C$2:$C$9,MATCH($G2&H$1,$A$2:$A$9&$B$2:$B$9,0)),""),"",IFERROR(LOOKUP(2,1/SEARCH($G2&H$1,$A$2:$A$9&$B$2:$B$9),$C$2:$C$9),"")))," ",",")
Press CTRL+SHIFT+ENTER to enter array formulas.
Thanks to you both, unfortunately it seems textjoin isn’t available for excel 2016…

Thanks to Jtakw but there are more than 2 matches in my data so this won’t quiet work.

Any other ideas or leads ? Thanks
 
Upvote 0
Any other ideas or leads ?
You could employ a user-defined function like this. To implement ..
1. Right click the sheet name tab and choose "View Code".
2. In the Visual Basic window use the menu to Insert|Module
3. Copy and Paste the code below (you can use the icon at the top right of the code pane below) into the main right hand pane that opens at step 2.
4. Close the Visual Basic window.
5. Enter the formula as shown in the screen shot below and copy across and down.
6. Your workbook will need to be saved as a macro-enabled workbook (*.xlsm)

VBA Code:
Function Who(rData As Range, sShop As String, sRegion As String) As String
  Dim d As Object
  Dim a As Variant
  Dim i As Long
  
  Set d = CreateObject("Scripting.Dictionary")
  a = rData.Value
  For i = 1 To UBound(a)
    d(a(i, 1) & "|" & a(i, 2)) = d(a(i, 1) & "|" & a(i, 2)) & "," & a(i, 3)
  Next i
  Who = Mid(d(sShop & "|" & sRegion), 2)
End Function

Manatarms.xlsm
ABCDEFGHI
1ShopRegionNameNorthSouth
2ANorthDaveADave,Mike 
3BSouthBobB Bob,Larry
4CNorthTonyCTony 
5DSouthGaryD Gary
6ENorthSteveESteve 
7FSouthTrevorF Trevor
8BSouthLarry
9ANorthMike
10
Sheet1
Cell Formulas
RangeFormula
H2:I7H2=Who($A$2:$C$9,$G2,H$1)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,382
Messages
6,171,767
Members
452,422
Latest member
rlynchbro

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