Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help on code to sample data
Hi
Not sure if this will help or not, but! You could try this link which is for a random number generator. You may be able to reconfigure it to select employees instead of numbers. https://www.get-digital-help.com/201...tery-in-excel/ HTH Mark. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help on code to sample data
thanks Mark
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sample code | Excel Programming | |||
Any sample code to verify data? | Excel Programming | |||
do anybody have a sample code for executing excel macro from vb code?<eom | Excel Programming | |||
Need sample code | Excel Programming | |||
Need Sample VBA Code | Excel Programming |