ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   select for choosing (https://www.excelbanter.com/excel-programming/396832-select-choosing.html)

Jonathan

select for choosing
 
Dear guys, I have a small urgent problem.

I have more than 10000 lines of data in one spreadsheet. I am trying to
select the lines in every 5 lines in this sheet and copy it to another.

at early stage of learning VB, and really couldnt find the right way.

Thx

Zone[_3_]

select for choosing
 
Do you mean you want to copy row 1 to another sheet, skip rows 2-4, copy row
5 to the next row on the other sheet, skip rows 6-9, copy row 10, and so on?

"Jonathan" wrote in message
...
Dear guys, I have a small urgent problem.

I have more than 10000 lines of data in one spreadsheet. I am trying to
select the lines in every 5 lines in this sheet and copy it to another.

at early stage of learning VB, and really couldnt find the right way.

Thx




Jonathan

select for choosing
 
Yes, exactly.

"Zone" wrote:

Do you mean you want to copy row 1 to another sheet, skip rows 2-4, copy row
5 to the next row on the other sheet, skip rows 6-9, copy row 10, and so on?

"Jonathan" wrote in message
...
Dear guys, I have a small urgent problem.

I have more than 10000 lines of data in one spreadsheet. I am trying to
select the lines in every 5 lines in this sheet and copy it to another.

at early stage of learning VB, and really couldnt find the right way.

Thx





Zone[_3_]

select for choosing
 
Johnathan, my math was a little off! Beginning with row 1 and skipping 5
each time would copy row 1,6,11, and so on. Is that what you want? The
following code copies from Sheet1 and pastes in Sheet2. Copy this code and
paste in a standard module and see if it does what you want. James

Sub CopyEvery5th()
Dim j As Long, k As Long, BtmRow As Long
Worksheets("Sheet2").Cells.Clear
Worksheets("Sheet1").Activate
BtmRow = Cells(Rows.Count, "a").End(xlUp).Row
k = 1
For j = 1 To BtmRow Step 5
Rows(j).EntireRow.Copy Destination:=Worksheets("Sheet2").Cells(k,
"a")
k = k + 1
Next j
End Sub

"Jonathan" wrote in message
...
Yes, exactly.

"Zone" wrote:

Do you mean you want to copy row 1 to another sheet, skip rows 2-4, copy
row
5 to the next row on the other sheet, skip rows 6-9, copy row 10, and so
on?

"Jonathan" wrote in message
...
Dear guys, I have a small urgent problem.

I have more than 10000 lines of data in one spreadsheet. I am trying to
select the lines in every 5 lines in this sheet and copy it to another.

at early stage of learning VB, and really couldnt find the right way.

Thx








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

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