lundi 30 mars 2015

Copy all the columns vertically in a spreadsheet


set ws1 As SheetA
set ws2 As Target
With ws1
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
End With
Lastrow = ws1.Range("B" & Rows.Count).End(xlUp).Row
For i = 1 To Lastcol
For l = 4 To lastrow
ws1.Cells(l, i).Copy ws2.Range("a65536").End(xlUp).Offset(1, 0)
Next l
Next i


I am trying to copy all the columns in one sheet to another sheet one below the another. Basically copying Column A of Sheet1 to Column A of sheet2 and then column B of sheet1 below column A of sheet2 . Data starts from row 4th of sheet A in every column, so I kept the second for loop running from 4. Any help is greatly appreciated as I am stuck for hours now. When I run the code it goes in to infinite loop.


Aucun commentaire:

Enregistrer un commentaire