Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Need help with the following: I've a cell that is calculated with the random function I need a procedure that simulates me hiting the F9 button and copying the result to a column so I can make a statistic to see how many values are above a certain value? lets say I need 100 values to have a representative sample. How can I make this? Please help. Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Give this subroutine a try...
"Diogo" wrote in message ... Hi Need help with the following: I've a cell that is calculated with the random function I need a procedure that simulates me hiting the F9 button and copying the result to a column so I can make a statistic to see how many values are above a certain value? lets say I need 100 values to have a representative sample. How can I make this? Please help. Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Give this subroutine a try...
Sub GenerateValues(NumberOfTimes As Long, ColumnLocation As Variant, StartRow As Long) Dim X As Long Static AlreadyRun As Boolean If Not AlreadyRun Then Randomize AlreadyRun = True End If For X = 1 To NumberOfTimes Cells(StartRow + X - 1, ColumnLocation).Value = Rnd Next End Sub Simply call it from within your own code passing in the three arguments. For example, to create 100 random values greater than or equal to 0 and less than 1 (you didn't specify any range of numbers to draw your values from, so I went with the default output of the Rnd function), you would use a statement similar to this... GenerateValues 100, "F", 3 which will place those random values in F3 to F102. Note, you can also use the column's numerical designation in place of its letter designation if you want... GenerateValues 100, 6, 3 Rick "Diogo" wrote in message ... Hi Need help with the following: I've a cell that is calculated with the random function I need a procedure that simulates me hiting the F9 button and copying the result to a column so I can make a statistic to see how many values are above a certain value? lets say I need 100 values to have a representative sample. How can I make this? Please help. Thanks. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Looking at the code I might have been a bit simple in my explainations.
The cell (C26) whose value I want to copy one hundred times is the result of a sum of several other cells whose values are calculated by the rand function. I just want to copy that cell 100 times to a column. What I need is a automated process that mimics me punchin the F9 button, going to the C26 cell and copying it to for example column F row 3, and repeat this process 99 more time so at the end I can see how many values obtained are grater then a certain value. This I can do manualy, of course. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Does this do what you want?
Sub GenerateValues(NumberOfTimes As Long, ColumnLocation As Variant, _ StartRow As Long) Dim X As Long Const CopyCell As String = "C26" For X = 1 To NumberOfTimes Cells(StartRow + X - 1, ColumnLocation).Value = Range(CopyCell) Application.Calculate Next End Sub Rick "Diogo" wrote in message ... Looking at the code I might have been a bit simple in my explainations. The cell (C26) whose value I want to copy one hundred times is the result of a sum of several other cells whose values are calculated by the rand function. I just want to copy that cell 100 times to a column. What I need is a automated process that mimics me punchin the F9 button, going to the C26 cell and copying it to for example column F row 3, and repeat this process 99 more time so at the end I can see how many values obtained are grater then a certain value. This I can do manualy, of course. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do I record this in a macro?
|
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It depends on how you want to "kick it off" (you didn't tell us that). Create a macro like this...
Sub GetMyRandomNumbers() GenerateValues 100, "F", 3 End Sub and execute it by pressing Alt+F8 from your spreadsheet. Or you can add a CommandButton to your spreadsheet and call the macro from its Click event like this... Private Sub CommandButton1_Click() GenerateValues 100, "F", 3 End Sub Or you can "kick it off" from a number of other different ways... it kind of depends on what you want to do. Rick "Diogo" wrote in message ... Do I record this in a macro? |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Forget it
My mistake It works fine. Thanks a lot. "Diogo" wrote: Hi Need help with the following: I've a cell that is calculated with the random function I need a procedure that simulates me hiting the F9 button and copying the result to a column so I can make a statistic to see how many values are above a certain value? lets say I need 100 values to have a representative sample. How can I make this? Please help. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can I random sample from a set until every sample is selected? | Excel Discussion (Misc queries) | |||
Random Sample | Excel Worksheet Functions | |||
How do I make a random sample? | Excel Discussion (Misc queries) | |||
random sample | Excel Worksheet Functions | |||
Random Sample Without Duplication | Excel Discussion (Misc queries) |