Transposing multiple rows into single column

gaurar

New Member
Joined
Mar 5, 2019
Messages
2
Hi,

I need help to convert multiple rows of data into single column question is, here data varies from row to row

Row 1: a b c
Row 2: 1 2 3 4
Row 3: a b c d e

Result needed:

a
b
c
1
2
3
4
a
b
c
d
e
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
This assumes you have less than or equalt to 16.384 cells of data in your data set.

Code:
Sub t()
    For Each c In Range("A2", Cells(Rows.Count, 1).End(xlUp))
        Range(c, Cells(c.Row, Columns.Count).End(xlToLeft)).Cut Cells(1, Columns.Count).End(xlToLeft).Offset(, 1)
    Next
    Range("A1", Cells(1, Columns.Count).End(xlToLeft)).Copy
    Range("A2").PasteSpecial xlPasteValues, Transpose:=True
    Rows(1).Delete
End Sub
 
Upvote 0
Here is an alternative method if you do have a large data set.

Code:
Sub t()
For i = Cells.Find("*", , xlValues, xlPart, xlByRows, xlPrevious).Row To 1 Step -1
    cnt = Range(Cells(i, 1), Cells(i, Columns.Count).End(xlToLeft)).Columns.Count
    txp = Application.Transpose(Range(Cells(i, 1), Cells(i, Columns.Count).End(xlToLeft)))
    Rows(i).ClearContents
    Cells(i + 1, 1).Resize(cnt - 1).Insert xlShiftDown
    Cells(i, 1).Resize(cnt) = txp
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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