Copy and paste data in multiple columns in to one column

MrPink1986

Board Regular
Joined
May 1, 2012
Messages
234
Hi there,

I have data in multiple columns on Sheet "Fields" - from A-AS. Each column varies in data and has 1-100 rows populated.
I wish to take all this data from these columns and paste them into one column on the "Sheet3" tab.

On the fields tab there is a header row which I do not require - how would i best approach this?
I need some type of loop to go though the columns on the fields tab I guess?

Thanks in advance for the help.
 

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
8,600
When you say:
Each column varies in data
do you mean that they all have the same number of rows populated but the number of rows can vary or do you mean that each column can have a different number of rows populated?
 

EFANYoutube

Board Regular
Joined
May 19, 2017
Messages
52
Give this a go
Code:
Sub Consolidate()
    Dim FromSheet, ToSheet As Worksheet
    Dim LastRow, ColumnNumber As Integer
    With Application
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
    End With
    Set FromSheet = ThisWorkbook.Sheets("Fields")
    Set ToSheet = ThisWorkbook.Sheets("Sheet3")
    
    LastRow = 2
    
    For ColumnNumber = 1 To 45
        With FromSheet
            .Range(.Cells(2, ColumnNumber), .Cells(.Cells(Rows.Count, ColumnNumber).End(xlUp).Row, ColumnNumber)).Copy
        End With
        ToSheet.Cells(LastRow, 1).PasteSpecial xlPasteValues
        LastRow = ToSheet.Cells(2, 1).End(xlDown).Row + 1
    Next ColumnNumber
    With Application
        .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
    End With
End Sub
 

MrPink1986

Board Regular
Joined
May 1, 2012
Messages
234
This has worked perfectly for me thanks so much ;)
Give this a go
Code:
Sub Consolidate()
    Dim FromSheet, ToSheet As Worksheet
    Dim LastRow, ColumnNumber As Integer
    With Application
        .Calculation = xlCalculationManual
        .ScreenUpdating = False
    End With
    Set FromSheet = ThisWorkbook.Sheets("Fields")
    Set ToSheet = ThisWorkbook.Sheets("Sheet3")
    
    LastRow = 2
    
    For ColumnNumber = 1 To 45
        With FromSheet
            .Range(.Cells(2, ColumnNumber), .Cells(.Cells(Rows.Count, ColumnNumber).End(xlUp).Row, ColumnNumber)).Copy
        End With
        ToSheet.Cells(LastRow, 1).PasteSpecial xlPasteValues
        LastRow = ToSheet.Cells(2, 1).End(xlDown).Row + 1
    Next ColumnNumber
    With Application
        .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
    End With
End Sub
 

Forum statistics

Threads
1,085,047
Messages
5,381,381
Members
401,735
Latest member
ranjithr

Some videos you may like

This Week's Hot Topics

Top