The following macro takes information from one sheet and puts it on another (basically swaps the order of the columns):
Sub SSETransfer()
Dim rFirstBlank As Range
Dim iRowCount As Integer
Dim sCol As String
Set rFirstBlank = Sheet1.Cells.SpecialCells(xlCellTypeLastCell)
iRowCount = Sheet2.Range("A65536").End(xlUp).Row - 1
sCol = "A"
Sheet1.Range(sCol & rFirstBlank.Row + 1, sCol & rFirstBlank.Row + iRowCount) _
= Sheet2.Range("A2", Range("A65536").End(xlUp).Offset(1, 0)).Value
sCol = "B"
Sheet1.Range(sCol & rFirstBlank.Row + 1, sCol & rFirstBlank.Row + iRowCount) _
= Sheet2.Range("D2", Range("D65536").End(xlUp).Offset(1, 0)).Value
sCol = "C"
Sheet1.Range(sCol & rFirstBlank.Row + 1, sCol & rFirstBlank.Row + iRowCount) _
= Sheet2.Range("R2", Range("R65536").End(xlUp).Offset(1, 0)).Value
sCol = "D"
Sheet1.Range(sCol & rFirstBlank.Row + 1, sCol & rFirstBlank.Row + iRowCount) _
= Sheet2.Range("N2", Range("N65536").End(xlUp).Offset(1, 0)).Value
End Sub
It works perfectly, but only if Sheet2 is active - why is this?
Secondly, I am doing the same operation for around 20 columns - could I turn this into a loop?
Thanks for reading.
Bookmarks