Controlling odd even rows when pasting data

G

Guest

I want to paste data into an excel sheet.
But I want to paste one large amount of data into even rows, then an equally
large amount of it into odd rows.

How do I direct the data to be pasted to only the assigned rows?

est 3000 to five thousand rows of data into each paste.

Thanks in advance


(e-mail address removed)
 
J

Jim Cone

John,

This code does the data transfer for the even rows only...

'---------------------------------------
'Transfer data from each row in rngTwo into
'the even numbered rows in rng one.
'Jim Cone - San Francisco, USA - Feb 23, 2005

Sub OddManOut()
Dim lngR As Long
Dim lngN As Long
Dim rngOne As Excel.Range
Dim rngTwo As Excel.Range

'rngOne must be have twice as many rows as rngTwo
Set rngOne = Range("A1:D40") 'Change to the applicable range
Set rngTwo = Range("E1:H20") 'ditto

For lngR = 1 To rngOne.Rows.Count
If rngOne.Rows(lngR).Row Mod 2 = 0 Then
lngN = lngN + 1
rngOne.Rows(lngR).Value = rngTwo.Rows(lngN).Value
End If
Next 'lngR
End Sub
'---------------------------------------
Regards,
Jim Cone
San Francisco, USA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top