How to stack columns from left to right into one column in Excel?
Supposing there are multiple columns, the job is to stack the columns from left to right into one single column as below screenshot shown. Except manually move the columns one by one, are there any tricks on solving this in Excel?
In Excel, there is no built-in function can handle this job, but, the VBA code can help you.
1. Press Alt +F11 keys, then in the Microsoft Visual Basic for Applications window, click Insert > Module to create a new blank module.
2. Copy and paste below code to the Module.
VBA: Stack columns into one
Sub StackColumns() 'UpdatebyExtendoffice20180814 Dim xSRg, xDRg As Range Dim xDWS As Worksheet Dim xIntDR, xIntDC, xI As Long Dim xFNumR, xFNumC As Long On Error GoTo Err1 Set xSRg = Application.InputBox("Select Columns:", "Kutools for Excel", xTxt, , , , , 8) If xSRg Is Nothing Then Err1: Application.ScreenUpdating = True Exit Sub End If Set xDRg = Application.InputBox("Select a cell to place result:", "Kutools for Excel", xTxt, , , , , 8) If xDRg Is Nothing Then Exit Sub End If Application.ScreenUpdating = False Set xDWS = xDRg.Worksheet xIntDR = xDRg.Row xIntDC = xDRg.Column xI = 0 For xFNumC = 1 To xSRg.Columns.Count For xFNumR = 1 To xSRg.Rows.Count Set xDRg = xDWS.Cells(xIntDR + xI, xIntDC) xDRg.Value = xSRg.Cells(xFNumR, xFNumC).Value xI = xI + 1 Next xFNumR Next xFNumC Application.ScreenUpdating = True End Sub
3. Press F5 key to run the code, a dialog pops out for you to select the columns you will stack into one.
4. Click OK, select a cell to place the result.
5. Click OK to finish. Now the selected columns have been stacked into one column.
If you have Kutools for Excel installed in Excel, you can use the Transform Range utility to handle this job.
|Kutools for Excel, with more than 200 handy functions, makes your jobs easier.|
After installing Kutools for Excel, please do as below:（Free Download Kutools for Excel Now!)
Tabbed browsing & editing multiple Excel workbooks/Word documents as Firefox, Chrome, Internet Explore 10!
You may be familiar to view multiple webpages in Firefox/Chrome/IE, and switch between them by clicking corresponding tabs easily. Here, Office Tab supports similar processing, which allow you to browse multiple Excel workbooks or Word documents in one Excel window or Word window, and easily switch between them by clicking their tabs. Click for free 30-day trial of Office Tab!
You are guest
or post as a guest, but your post won't be published automatically.
- To post as a guest, your comment is unpublished.· 5 months agoI will be eternally grateful to you. Thank you so much!
- To post as a guest, your comment is unpublished.· 7 months agoA Word cheat to do the same:
- copy all your rows and lines in Excel
- paste without into a Word doc
- ctrl + h (find and replace)
- copy a tabulation space between two rows
- paste into search bar
- replace by tabs by line breaks "^l"
All your cells are now in column in your Word doc.
Copy paste them into Excel: done!