Copy Values from Multiple Columns to 2 Columns

kh4w4r

New member
Joined
Aug 12, 2013
Messages
6
Reaction score
0
Points
0
Hello All,

I am using following code to copy values from multiple columns to one column.

Code:
Sub test()    Dim lastCol As Long, lastRowA As Long, lastRow As Long, i As Long


    'find last non empty column number'
    lastCol = Cells(1, Columns.Count).End(xlToLeft).Column


    'loop through all columns, starting from column B'
    For i = 2 To lastCol
        'find last non empty row number in column A'
        lastRowA = Cells(Rows.Count, "A").End(xlUp).Row
        'find last non empty row number in another column'
        lastRow = Cells(Rows.Count, i).End(xlUp).Row


        'copy data from another column'
        Range(Cells(1, i), Cells(lastRow, i)).Copy
        'paste data to column A'
        Range("A" & lastRowA + 1).PasteSpecial xlPasteValues


        'Clear content from another column. if you don't want to clear content from column, remove next line'
        Range(Cells(1, i), Cells(lastRow, i)).ClearContents
    Next i


    Application.CutCopyMode = False
End Sub


I am after a code to do do exactly the same but copy two columns now.
 
If you are able to create this code, you undoubtedly are able to adapt it to your new requirement.
 
If you are able to create this code, you undoubtedly are able to adapt it to your new requirement.


I have tried my head stopped working and I can't figure it out.
 
Back
Top