Hi,
I am trying to write a code that will give a random group of 23 people,how likely is it that two people have the same birthday. i need to write a program that creates a random date array from 1 to 23 (being the number of people) and to assign each of the 23 people a random date integer from 1 to 365 the program needs to check all the dates to see if theres are any matching dates and to be repated 100 times for how many matching birthdays there would be and i need the answer to be around 50 to 60%.
so far i have got a code that will randomly display a date but im not to sure on the rest would some one be able to help me out
thanks
this is the code i have so far
Sub GenerateRandomNumberInRange()
Dim MaxNumber As Integer
Dim MinNumber As Integer
Dim RandomNumber As Integer
MinNumber = 1
MaxNumber = 365
RandomNumber = Int((Rnd * (MaxNumber - MinNumber + 1)) + MinNumber)
Debug.Print DateSerial(1983, 1, RandomNumber)
'
msg = DateSerial(1983, 1, RandomNumber)
MsgBox msg
End Sub
I am trying to write a code that will give a random group of 23 people,how likely is it that two people have the same birthday. i need to write a program that creates a random date array from 1 to 23 (being the number of people) and to assign each of the 23 people a random date integer from 1 to 365 the program needs to check all the dates to see if theres are any matching dates and to be repated 100 times for how many matching birthdays there would be and i need the answer to be around 50 to 60%.
so far i have got a code that will randomly display a date but im not to sure on the rest would some one be able to help me out
thanks
this is the code i have so far
Sub GenerateRandomNumberInRange()
Dim MaxNumber As Integer
Dim MinNumber As Integer
Dim RandomNumber As Integer
MinNumber = 1
MaxNumber = 365
RandomNumber = Int((Rnd * (MaxNumber - MinNumber + 1)) + MinNumber)
Debug.Print DateSerial(1983, 1, RandomNumber)
'
msg = DateSerial(1983, 1, RandomNumber)
MsgBox msg
End Sub