ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Controlling odd even rows when pasting data (https://www.excelbanter.com/excel-discussion-misc-queries/14609-controlling-odd-even-rows-when-pasting-data.html)

[email protected]

Controlling odd even rows when pasting data
 
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




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



"

wrote in message ...

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



All times are GMT +1. The time now is 03:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com