View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.newusers,microsoft.public.excel.programming
Jim Campbell Jim Campbell is offline
external usenet poster
 
Posts: 5
Default Random Function in VB

Bernie,
1)Date is stored in Lottery .xls in column 4 , want to get number with same
date and store in GroupCount(see below)
if the date is different, then exit and go to step 2

Sub Check_Start_Date()
Check = True: GroupCount = 0 ' Initialize variables.
Do ' Outer loop.
Do While StartDate = StartDate ' Inner loop.
GroupCount = GroupCount + 1 ' Increment Counter.
If StartDate < StartDate Then 'If condition is True.
Check = False ' Set value of flag to False.
Exit Do ' Exit inner loop.
End If
Loop
Loop Until Check = False ' Exit outer loop immediately
End Sub

2) Yes, the value from GroupCount will be used to generate the Random number
, and within the value put out the random number to column 5 in the
Lottery.xls spreadsheet i.e.: GroupCount is 8, put out value from 1-8 in
column 5 all within the same date range(GroupCount with the same date)

3) I don't know if it is more efficient to output random number within step
2 and a new value will be put out every time within the date range criteria,
the new column will have the Random number generated from the function

Hope I made this clear, your input is appreciated
"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Jim,

See my questions in-line.

HTH,
Bernie
MS Excel MVP

"Jim Campbell" wrote in message
...
1) Count the number of occurrences with the same start date and store

them
in a variable


Where is the start date stored? Which cells do you want to compare to the
start date? (Give sheet name and cell addresses)

2) Take variable and pass it to random function to output random number
within range of variable (ie:1-8)


Do you mean you want a random number between 1 and the count from step 1?
Where do you want the random number put?

3) Output Random number to Lottery Spreadsheet within the scope of the
variable i.e.: insert column and output number


A new column inserted everytime? What should the new column have in it?

Does not sound difficult


It shouldn't be hard, but you need to be more precise in your

descriptions:
"I want to read the date in cell A1 of "Sheet1", and compare it to cells
B1:B10 of "Sheet2" and then.....