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?
[TABLE="width: 174"]
<!--StartFragment--> <colgroup><col width="87" span="2" style="width:65pt"> </colgroup><tbody>[TR]
[TD="width: 87"]Sales Rep[/TD]
[TD="width: 87"]Product Code[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN099[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN100[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN101[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN102[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN103[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN104[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN105[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN106[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN107[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN108[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN109[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN110[/TD]
[/TR]
[TR]
[TD]Tim[/TD]
[TD]DDU09[/TD]
[/TR]
[TR]
[TD]Tim[/TD]
[TD]DDU10[/TD]
[/TR]
[TR]
[TD]Tim[/TD]
[TD]DDU11[/TD]
[/TR]
[TR]
[TD]Thomas[/TD]
[TD]DN098[/TD]
[/TR]
[TR]
[TD]Adria[/TD]
[TD]UI987[/TD]
[/TR]
[TR]
[TD]Adria[/TD]
[TD]UI988[/TD]
[/TR]
<!--EndFragment--></tbody>[/TABLE]

Here is how I would like to have
[TABLE="width: 684"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Sales Rep[/TD]
[TD]Product Code[/TD]
[/TR]
[TR]
[TD]Sue[/TD]
[TD]DN099;DN100;DN101;DN102;DN103;DN104;DN105;DN106;DN107;DN108;DN109;DN110[/TD]
[/TR]
[TR]
[TD]Tim [/TD]
[TD]DDU09;DDU10;DDU11[/TD]
[/TR]
</tbody>[/TABLE]


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

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
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,223,754
Messages
6,174,311
Members
452,554
Latest member
Louis1225

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