Selecting every "X" files

tjak

Board Regular
Joined
Jan 2, 2003
Messages
117
I need to audit files produced by others based on a numerical sampling. For instance, I may need to audit every 5th file for one person, but every 12th file for person 2.
Does XL (2007) have an easier way to select every "Xth" file than numbering the lines manually?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
do you mean lines or files

If it is files then you will need to interrogate the disk directory and use some rules to decide how files are ordered.

If you mean lines then there are number of different ways but the easiest is probably some use of the modulus functionality


Code:
Dim sampleRate as Integer
Dim CurrentRow as Long
 
sampleRate = 5
 
For CurrentRow = 1 to ActiveSheet.UsedRange.Rows.Count
  If currentRow mod SampleRate = 0 then
    ' Do something with the row in here...
  End If
next  CurrentRow
 
Upvote 0
It doesn't have to be a module, it could be VBA code in the worksheet.

If you mean you would rather not use VBA then the only thing I can think of is to put a formula into every row of the the data set

IV10 =MOD(ROW(A10),5)

and then filter on the result of that cell being 0. The 5 is the nth value that you want to filter by.
 
Upvote 0

Forum statistics

Threads
1,225,071
Messages
6,182,674
Members
453,131
Latest member
BeLocke

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