Column to row

shadymedhat

New Member
Joined
Oct 30, 2019
Messages
15
Hello fellows,

I have a table of 2 columns “unique code” and “email” ,so the case is that one code could have many emails, so i want show all emails for specific code at one row..


Thank U
 
Last edited by a moderator:
using Power Query

Unique codeemailUnique codeemail.1email.2email.3
10509-10email@domain.com 110509-10email@domain.com 1
10509-26email@domain.com 210509-26email@domain.com 2email@domain.com 3
10509-26email@domain.com 310509-27email@domain.com 4
10509-27email@domain.com 410537-08email@domain.com 5email@domain.com 6email@domain.com 7
10537-08email@domain.com 5
10537-08email@domain.com 6
10537-08email@domain.com 7

Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Group = Table.Group(Source, {"Unique code"}, {{"Count", each _, type table}}),
    List = Table.AddColumn(Group, "email", each List.Distinct(Table.Column([Count],"email"))),
    Extract = Table.TransformColumns(List, {"email", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    SplitCount = Table.AddColumn(Extract, "Split Count", each List.Count(Text.Split([email],","))),
    MaxCount = List.Max(SplitCount[Split Count]),
    Split = Table.SplitColumn(Extract, "email", Splitter.SplitTextByDelimiter(","), MaxCount)
in
    Split[/SIZE]

btw. share excel file not a picture, no one want to re-type data from the picture
 
Last edited:
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi
Try this come in a normal module
Code:
Sub test()
    Dim a As Variant, i, itm, x
    a = Range("a2:a" & Cells(Rows.Count, 1).End(xlUp).Row).Resize(, 2)
    With CreateObject("scripting.dictionary")
        For i = 1 To UBound(a)
            If a(i, 1) <> 0 Then
                If Not .exists(a(i, 1)) Then
                    .Add a(i, 1), a(i, 2)
                Else
                    .Item(a(i, 1)) = .Item(a(i, 1)) & "," & a(i, 2)
                End If
            End If
        Next
        itm = .Items
        Cells(1, 1).Resize(, 2).Copy Cells(1, 1).Offset(, 3).Resize(, 2)
        Cells(1, 1).Offset(1, 3).Resize(.Count) = Application.Transpose(.Keys)
        For i = 0 To .Count - 1
            x = Split(itm(i), ",")
            If UBound(x) < 1 Then
                Cells(i + 1, 1).Offset(1, 4) = itm(i)
            Else
                Cells(i + 1, 1).Offset(1, 4).Resize(, UBound(x) + 1) = x
            End If
        Next
    End With
End Sub
 
Upvote 0
Also please see this function. thanks.

Excel 2013/2016
ABCDE
14Unique CodeEmail1Email2Email3Email4
1510509-10email@domain.com1
1610509-26email@domain.com2email@domain.com3
1710509-27email@domain.com4
1810537-08email@domain.com5email@domain.com6email@domain.com7

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet4

Array Formulas
CellFormula
B15{=IFERROR(INDEX($B$2:$B$8,SMALL(IF($A15=$A$2:$A$8,ROW($A$2:$A$8)- (ROW($A$2))+1,""),COLUMN()-1)), "")}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,825
Members
449,190
Latest member
rscraig11

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