Forum Discussion
albatros8
Jun 20, 2024Copper Contributor
Excel multiple columns to rows
Dear, I would kindly ask for help. I'm using Excel 2013. I have 16 columns and big numbers of rows (e.g. 300+) I would like that each row, would be placed next to the ending (16th) column. ...
OliverScheurich
Jun 20, 2024Gold Contributor
Sub transform()
Dim i As Long, j As Long, k As Long, m As Long
Dim arr
i = Range("A" & Rows.Count).End(xlUp).Row
ReDim arr(1 To 1, 1 To i * 16)
k = 1
For m = 1 To i
For j = 1 To 16
arr(1, k) = Cells(m, j).Value
k = k + 1
Next j
Next m
Cells(i + 2, 1).Resize(1, i * 16).Value = arr
End Sub
In the attached sample file you can click the button in cell R2 to run the macro. The result is returned 2 rows below the database of 16 columns with many rows. This macro works in my Excel 2013 file.