selecting every fifth row of large spreadsheet

Redman7x

New Member
Joined
Oct 6, 2008
Messages
1
I have a large spreadsheet, 32,000 rows X 13 columns and I need to create graphs of the data but 32000 data points is too many. I need to select every fifth or Nth row and copy it to another sheet. I think a macro would work, but i don't know how to write them. Can anyone please help me???
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Here's a possible formula solution.
Insert a helper column somewhere, let's say it's Col A.

Let's say your data is in the range from B2 downwards and to the right.
In A1, input 5, or whatever N is.
In A2, put this formula
Code:
=if(mod(row()-1,a$1)=0,1,0)
This will put a 0 on all rows, except the Nth rows, which will have a 1.
Then use Data Filter to select these rows, and copy them across.

Once you've done this, you can easily record a macro while you do it.
 
Upvote 0
=OFFSET(Sheet1!$A$1,ROW()*5,0)

You could also use this in your destination sheet. Change the sheet name, and fill across/down.

If you really wanted to use code this should work

Code:
Dim i As Long
For i = 1 To Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp) Step 5
    Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).EntireRow.Value = Sheets("Sheet1").Rows(i).Value
Next i

But both formula approaches will probably be more flexible for you if you need to make changes in the future.
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,216,163
Messages
6,129,223
Members
449,495
Latest member
janzablox

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top