macro for pasting

C

CMD

Hi. I want to paste a list from 1 worksheet to another. The catch is the
list I am copying from is consecutive (row 1, row 2, row 3, etc..). I want
to paste it such that it skips 2 rows. So the list will be pasted in row 1,
row 4, row 7, etc. Thanks.
 
N

ngenear11

you can begin by recording a macro that copies the text and pastes.
then edit the macro and change where it selects to paste.
ie:

'put your code to copy
Worksheet("sheet1").Activate 'activates the sheet you want to copy to
Range("A1").Select 'gives you a starting position to
paste
counter=0
ActiveCell.Offset(counter,0)
Selection.Paste
counter=counter+3


you can then implement this same approach to copy the code and just use
counter=counter +1 to copy all of the rows.-you can control this with a
loop and have it stop when the cell is empty-
ie:
do
'copy whatever you want
loop until IsEmpty(ActiveCell.Offset(counter2,0))
 
D

Dave Peterson

One way:

Option Explicit
Sub testme()
Dim fWks As Worksheet
Dim tWks As Worksheet
Dim iRow As Long

Set fWks = Worksheets("sheet1")
Set tWks = Worksheets("sheet2")

With fWks
For iRow = 1 To .Cells(.Rows.Count, "A").End(xlUp).Row
.Rows(iRow).Copy _
Destination:=tWks.Cells(iRow * 2 - 1, "A")
Next iRow
End With

End Sub


But if you're doing this to make it look double spaced (for viewing or
printing), I think I'd just change the rowheights.

It'll make sorting/filtering/charting/etc much easier if you don't insert those
extra rows.
 
Top