annawilliams7227
New Member
- Joined
- Aug 16, 2009
- Messages
- 14
Hey guys,
I am trying to write a subroutine that will generate n random integers and output them one by one to consecutive cells in an empty column on my worksheet.
I am using "Inputbox" to prompt the user to enter how man numbers to generate (i.e the value of n). and I want each random interger to lie between 1 and 100.
The part i'm having trouble with is I want the value in the previous cell to be added to the new integer before teh new value is output (e.g. if value in the previous cell is 5 and the random current number is 4, the otuput value is 9)
Finally after the number generation process has occurred I want to calculate the average of those generated numbers.
This is waht i've managed to do so far (which is not much).. its probably really simple bu i'm so stuck!!
thanks for your help!!
Sub RndInt()
n = Val(InputBox("Enter number of values"))
For i = 1 To n
Range("EmptyColumn").Cells(i, 1).Formula = cumsum
cumsum = cumsum + WorksheetFunction.RandBetween(1, 100)
Next i
End Sub
I am trying to write a subroutine that will generate n random integers and output them one by one to consecutive cells in an empty column on my worksheet.
I am using "Inputbox" to prompt the user to enter how man numbers to generate (i.e the value of n). and I want each random interger to lie between 1 and 100.
The part i'm having trouble with is I want the value in the previous cell to be added to the new integer before teh new value is output (e.g. if value in the previous cell is 5 and the random current number is 4, the otuput value is 9)
Finally after the number generation process has occurred I want to calculate the average of those generated numbers.
This is waht i've managed to do so far (which is not much).. its probably really simple bu i'm so stuck!!
thanks for your help!!
Sub RndInt()
n = Val(InputBox("Enter number of values"))
For i = 1 To n
Range("EmptyColumn").Cells(i, 1).Formula = cumsum
cumsum = cumsum + WorksheetFunction.RandBetween(1, 100)
Next i
End Sub