HELP how to stack multiple columns into one column. Using (formula or vba code)

usui

Board Regular
Joined
Apr 20, 2020
Messages
55
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hi masters,

Can anyone help me with a formula for stacking multiple columns data into one column. wherein it copies per column not per row.

sample here:
1664380471184.png


I hope anyone has an idea using excel 2016 here..please help me
 
Yes please, the only data present in column H is the header( Result here). If you can move it to H2 that you be very great sir.
Here's the updated code:
VBA Code:
Sub Consolidate()
Dim lrow As Long
Dim i As Long
Dim j As Long
Dim DestCol As Integer
Dim NumOfCol As Integer
Dim DestCounter As Long

DestCol = 8 'Put the column number you'd like the results to go
NumOfCol = 5 'Put the number of columns that contain data

DestCounter = 2

For i = 2 To NumOfCol + 1
    lrow = Cells(Rows.Count, i).End(xlUp).Row
    For j = 2 To lrow
        If Cells(j, i) <> "" Then
            Cells(j, i).Copy Cells(DestCounter, DestCol)
            DestCounter = DestCounter + 1
        End If
    Next j
Next i

End Sub
 
Upvote 0
Solution

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Which Row is the top Row with data to be copied and pasted? Looks like you have a narrow Row as Row2
Does the data start in B2 or B3?
If it starts in B2, the suggestion in Post #14 will work. Another possible problem could be tat if the Cells below and to the right are not really empty cell.
If you run the suggested macro from Post #14 and when finished, hold down the Ctrl key and press End (Ctrl+End), where do you end up?
 
Upvote 0
Here's the updated code:
VBA Code:
Sub Consolidate()
Dim lrow As Long
Dim i As Long
Dim j As Long
Dim DestCol As Integer
Dim NumOfCol As Integer
Dim DestCounter As Long

DestCol = 8 'Put the column number you'd like the results to go
NumOfCol = 5 'Put the number of columns that contain data

DestCounter = 2

For i = 2 To NumOfCol + 1
    lrow = Cells(Rows.Count, i).End(xlUp).Row
    For j = 2 To lrow
        If Cells(j, i) <> "" Then
            Cells(j, i).Copy Cells(DestCounter, DestCol)
            DestCounter = DestCounter + 1
        End If
    Next j
Next i

End Sub
Hi Sir, sorry for the late reply. The code works like a charm thank you so much
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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