MrExcel Publishing
Your One Stop for Excel Tips & Solutions

copy every fifth row and paste

Posted by Gary on December 04, 2000 3:44 AM

Hi Peoples,
Could any one tell me please if it is possible to copy every fifth row and paste it to another worksheet using a Macro or VBA...thank you


Posted by Feargal Tierney on December 04, 2000 4:29 AM

if you have a loop that detects all the way to the bottom of you spreadsheet eg :--

For returncount = 2 To 20
If ActiveSheet.Cells(returncount, 1).Value <> "" Then
lastentry = returncount
End If

Then lastcount will be the last row with data in it, then create another loop which is :-

fifth = 1
for counter = 1 to lastcount
fifth = fifth + 1
if fifth = 5 then
'write the row somewhere'
fifth = 0

The above is not precise- and could be done in one loop, but it should give you the idea.