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,518
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,082,244
Messages
5,363,981
Members
400,772
Latest member
solbebe

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top