Converting Multiple Rows into One

jburns309

New Member
Joined
Feb 1, 2019
Messages
1
I need to reorganize data output as listed below:

Source export:
Column A | Column B
Patient A | Diagnosis Code 1
Patient A | Diagnosis Code 2
Patient A | Diagnosis Code 3

Ideal Output:
Column A | Column B | Column C | Column D
Patient A | Diagnosis Code 1 | Diagnosis Code 2 | Diagnosis Code 3

I'm new to VBA, so I'll need something easy to decipher.
Thank you!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

sandy666

Banned - Rules violations
Joined
Oct 24, 2015
Messages
7,499
you can try PowerQuery aka Get&Transform

PatientDiagnosePatientDiagnose.1Diagnose.2Diagnose.3
Patient A Diagnosis Code 1Patient ADiagnosis Code 1Diagnosis Code 2Diagnosis Code 3
Patient A Diagnosis Code 2
Patient A Diagnosis Code 3

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"Patient"}, {{"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Diagnose", each Table.Column([Count],"Diagnose")),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Diagnose", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Diagnose", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Diagnose.1", "Diagnose.2", "Diagnose.3"})
in
    #"Split Column by Delimiter"[/SIZE]
 

Watch MrExcel Video

Forum statistics

Threads
1,129,557
Messages
5,637,043
Members
416,955
Latest member
Gohar hussain

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
Top