Formula Help. (One condition transfer all)

Aberdham

Board Regular
Joined
Mar 8, 2018
Messages
163
Office Version
  1. 365
Platform
  1. Windows
Hey all,

I know it is possible to use index and aggregate to extract data row by row. But I would like to have all the data in 1 row. but got stuck there, Perhaps transpose?
Sales RepProduct Code
SueDN099
SueDN100
SueDN101
SueDN102
SueDN103
SueDN104
SueDN105
SueDN106
SueDN107
SueDN108
SueDN109
SueDN110
TimDDU09
TimDDU10
TimDDU11
ThomasDN098
AdriaUI987
AdriaUI988

<!--StartFragment--> <colgroup><col width="87" span="2" style="width:65pt"> </colgroup><tbody>
<!--EndFragment--></tbody>

Here is how I would like to have
Sales RepProduct Code
SueDN099;DN100;DN101;DN102;DN103;DN104;DN105;DN106;DN107;DN108;DN109;DN110
Tim DDU09;DDU10;DDU11

<colgroup><col><col></colgroup><tbody>
</tbody>


Thanks in adv.
 
Hi Aladin,

Would be in one cell please.

Thank you.


Book1
ABDE
1Sales RepProduct CodeSales RepProduct Code
2SueDN099sueDN099, DN100, DN101, DN102, DN103, DN104, DN105, DN106, DN107, DN108, DN109, DN110
3SueDN100timDDU09, DDU10, DDU11
4SueDN101
5SueDN102
6SueDN103
7SueDN104
8SueDN105
9SueDN106
10SueDN107
11SueDN108
12SueDN109
13SueDN110
14TimDDU09
15TimDDU10
16TimDDU11
17ThomasDN098
18AdriaUI987
19AdriaUI988
Sheet1


In D2 control+shift+enter, not just enter:

=TEXTJOIN(", ",1,IF($A$2:$A$19=$D2,$B$2:$B$19,""))

If the native function TEXTJOIN is not available on your system...

In D2 control+shift+enter, not just enter, and copy down:

=REPLACE(aconcat(IF($A$2:$A$19=$D2,", "&$B$2:$B$19,"")),1,2,"")

For this formula to work, add the following code for ACONCAT as a Module to your workbook using Alt+F11...

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

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi Aberdham,

I just wanted to clarify my Excel setup bit more clear.


Enter your data in range A1 to B19


Enter the following formula in D2 and copy it down

=COUNTIFS($A$2:A2,A2)


Enter the array formula in E2 using Shift + Ctrl + Enter and copy it down.

As you know, there will be curly brackets around the formula when entered correctly.

=IF(C2=1,INDEX($B$2:$B$19,MATCH(A2,$A$2:$A$19,0)),INDEX($D1:D$1,MATCH(1,((C2-1)=$C$1:C1)*(A2=$A$1:A1),0))&";"&B2)


Enter Sue in Cell A22 and enter the formula to pick all product codes against her name in one cell.

=INDEX($D$2:$D$19,SUMPRODUCT((MAX(ROW($D$2:$D$19)*(A22=$A$2:$A$19))-1)))

Kind regards

Saba
 
Upvote 0
Thank you so much both Aladin and Saba,

I decided to apply Aladin's approach since it is one straight formula.

Thanks a lot for your help !!:)
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,667
Members
449,462
Latest member
Chislobog

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