select for choosing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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?
 
Yes, exactly.

Zone said:
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?
 
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
 

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

Back
Top