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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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]
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

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