Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Paste in alternate rows

I have a source sheet which has the data set in consecutive rows in each of
four sheets. The data has to be copied and pasted in selected workbooks but
in every other row. My current procedure works well but is very slow. Is
there a more efficient way to accomplish this? The below represents this
portion of the operation.

Do

Workbooks(wbk1).Activate
Activecell.Offset(1,0).activate
Activecell.Copy
Workbooks(wbk2).Activate
Activecell.Offset(2,).Activate
Activecell.PasteSpecial

Loop until (certain conditions are encountered)
--
Thanks,

Jim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Paste in alternate rows

Jim,

try the code below, it worked for me in milliseconds for over 10,000
rows:


Sub PasteEveryOtherRow()
Dim wbk1, wbk2 As Workbook, _
i, j, lRow As Long

Set wbk1 = ActiveWorkbook
Set wbk2 = Workbooks.Add

i = 1
j = 2
lRow = wbk1.Sheets(1).Range("A65536").End(xlUp).Row

Do Until i = lRow

wbk2.Sheets(1).Cells(j, 1).Value = wbk1.Sheets(1).Cells(i,
1).Value
i = i + 1
j = j + 2

Loop

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Paste in alternate rows

Dave, I think you have solved it for me. A little editing to fit my
particular specs and I believe it will be just what I needed.

Thanks,

Jim


"Dave Miller" wrote:

Jim,

try the code below, it worked for me in milliseconds for over 10,000
rows:


Sub PasteEveryOtherRow()
Dim wbk1, wbk2 As Workbook, _
i, j, lRow As Long

Set wbk1 = ActiveWorkbook
Set wbk2 = Workbooks.Add

i = 1
j = 2
lRow = wbk1.Sheets(1).Range("A65536").End(xlUp).Row

Do Until i = lRow

wbk2.Sheets(1).Cells(j, 1).Value = wbk1.Sheets(1).Cells(i,
1).Value
i = i + 1
j = j + 2

Loop

End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula from consecutive rows to alternate rows? Neville Bailey[_2_] Excel Discussion (Misc queries) 2 March 25th 10 01:58 PM
Color alternate rows when after hiding selected rows Monk[_2_] Excel Worksheet Functions 6 June 7th 08 01:36 AM
sum alternate rows anand Excel Worksheet Functions 4 June 19th 07 07:59 AM
macro to paste data in alternate cells-pawan Pawan Excel Programming 7 June 21st 05 11:25 PM
Add alternate rows Teri Excel Worksheet Functions 6 March 16th 05 10:15 PM


All times are GMT +1. The time now is 06:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"