Hello All,
I am using following code to copy values from multiple columns to one column.
I am after a code to do do exactly the same but copy two columns now.
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.