lundi 30 mars 2015

Copying a range of column using a loop

Hi I want to copy all the columns of a worksheet in to another worksheet one below the another.



Sheet A

Column A B C ....................BL

ValueA ValueB ValueC..................ValueBL
ValueA2 ValueB2 ValueC2.................ValueBL2
. . . .
. . . .
ValueA10 ValueB10 ValueC10...............ValueBL10

Target Sheet

Value A
.
.
Value A10
Value B
.
.
Value B10
Value C
.
.
Value C10


and so on. Basically each column has multiple values(rows) and there are hundreds of column. I want to copy all the columns one below the another. This will require a loop , but I don't understand as how to use it. Because



set ws1 As SheetA
set ws2 As Target
Lastcol= ......
Lastrow=......
For i=1 to Lastcol
ws1.Range("?" & lastrow).copy ws2.Range("a65536").End(xlUP).Offset(1,0)
Next i


I am not getting as what to put instead of "?". Appreciate any help. Thanks.


Aucun commentaire:

Enregistrer un commentaire