View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
redeemed redeemed is offline
external usenet poster
 
Posts: 2
Default Help on code to sample data

I am in Excel 2010.

Working with very large data files generating samples for different managers .

I have my data in the Details tab of a spreadsheet the Managers Names are in C1 and to the end of column c & the employees Names are in D1 and scroll down...

In order to get my sample I run the sampler macro below.

In this macro I enter the n value that is the total number of the rows in the data. This data can contain data for multiple managers and their employees.

I then enter the Step value. which is give to me .
This could be like 2.5 or 23.7 or 4 or 110 it could be any number.

Issue is that I must have a sample of a minimum of two employees for each manager.

This sampler macro does not guarantee me a sample of at least two sample each for every employee Can this be fixed by modifying the code in the sampler macro below?

Thanks in advance, appreciate any enhancement of the code below as I am not a programmer.



Sub Sampler()
Source_Sheet = "Source"
Target_Sheet = "Target"


n = 2919 ' your last line of data on Sheet1
Target_Row = 1
Sheets(Target_Sheet).Select
For nCount = 1 To n Step 130 ' Enter the Sample Interval


Worksheets(Source_Sheet).Cells(nCount, 1).EntireRow.Copy
Worksheets(Target_Sheet).Cells(Target_Row, 1).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Target_Row = Target_Row + 1
Next


End Sub