Public Sub countNumbers()
Dim counts(9) As Long
Dim numberCounter As Long
Dim number As String
Dim numberToTest As Long
Const upperLimit As Long = 999
For numberCounter = 0 To upperLimit
number = Format(numberCounter, "00#")
For numberToTest = 0 To 9 'loop through the digits and see if any of them are in the draw number
If InStr(1, number, numberToTest) > 0 Then
counts(numberToTest) = counts(numberToTest) + 1
End If
Next
Next
MsgBox "0 = " & counts(0) & vbNewLine & _
"1 = " & counts(1) & vbNewLine & _
"2 = " & counts(2) & vbNewLine & _
"3 = " & counts(3) & vbNewLine & _
"4 = " & counts(4) & vbNewLine & _
"5 = " & counts(5) & vbNewLine & _
"6 = " & counts(6) & vbNewLine & _
"7 = " & counts(7) & vbNewLine & _
"8 = " & counts(8) & vbNewLine & _
"9 = " & counts(9) & vbNewLine
End Sub