Using VBA loops to turn a multiple row list into a single column

eg11

New Member
Joined
Apr 16, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I am trying to figure out how I can create a macro to loop through my data that is in 6 rows to a single column with no repeating headers. my data is in the form the top part and I am trying to transform it into the bottom part of the image.


excel.PNG
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Power Query Solution

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Grouped Rows" = Table.Group(Source, {"Column1"}, {{"Data", each _, type table [Column1=text, Column2=any]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Data],"Index",1,1)),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Data"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Columns", "Custom", {"Column2", "Index"}, {"Custom.Column2", "Custom.Index"}),
    #"Pivoted Column" = Table.Pivot(#"Expanded Custom", List.Distinct(#"Expanded Custom"[Column1]), "Column1", "Custom.Column2"),
    #"Removed Columns1" = Table.RemoveColumns(#"Pivoted Column",{"Custom.Index"})
in
    #"Removed Columns1"
Book3
ABCDEFGHI
1Column1Column2row 1row2row 3row 4row 5row 6
2row 1aaaaaabbbcccdddeeefff
3row2bbb112233445566
4row 3ccc
5row 4ddd
6row 5eee
7row 6fff
8row 111
9row222
10row 333
11row 444
12row 555
13row 666
Sheet1
 
Upvote 0
With a formula
Fluff.xlsm
ABCDEFGHI
1Column1Column2Row 1Row 2Row 3Row 4Row 5Row 6
2Row 1aaaaaabbbcccdddeeefff
3Row 2bbb112233445566
4Row 3ccc
5Row 4ddd
6Row 5eee
7Row 6fff
8Row 111
9Row 222
10Row 333
11Row 444
12Row 555
13Row 666
14
Main
Cell Formulas
RangeFormula
D1:I1D1=TOROW(UNIQUE(A2:A13))
D2:I3D2=WRAPROWS(B2:B13,6)
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,214,785
Messages
6,121,543
Members
449,038
Latest member
Guest1337

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