With this and your follow-up postings, you did a job of clarifying what you are doing. Unfortunately, there is still one very important detail that is unclear to me.
Your original question was how to do some things in Excel. So at this point, I would like to refer you to an uploaded Excel file that might clarify my comments below. But I am still just a "new member", and the draconian rules of this forum do not permit me to post a URL or even an email address to contact me directly.
I will do my best to represent the Excel solutions here. Alternatively, Google "Microsoft Answers" and post your Excel questions there. We should not discuss lottery strategies there. But at least I would be able to point you to Excel files and demonstrate Excel usage graphically.
Summarizing your several postings, "dr san" wrote:
``The code splits the numbers 0-9 [...] into three groups for low, medium and high numbers.
4 Ball1 Ball2 Ball3 Prob
5 L L L 2.7%
6 L L M 3.6%
7 L L H 2.7%
[....]
29 H H L 2.7%
30 H H M 3.6%
31 H H H 2.7%
[....]
Then we have the 1st position 3,4,5, because the groups were divided so H (0,1,2) L (3,4,5) M (6,7,8,9)
[....]
these permutations 27-30, covering 100% in any lottery?``
It is unclear to me how you determined those probabilities. It is unclear whether you simply counted wrong; or if understanding your computations might give us some insight into the answer to the point that is still unclear to me (below).
For the L L L case, is there only one combination (3 4 5), ignoring order; or are there six combinations, namely all permutations of 3 4 5?
To be clear, there are only 27 permutations (with replacement) of the LMH categories. Why do you keep saying 30?! (Rhetorical question.)
And those 27 categories would cover all 720 Pick3 permutations (without replacement) only if L L L covers all permutations of 3 4 5, and likewise for the other categories.
Suppose "ball1", "ball2" and "ball3" are in columns A, B and C starting in row 1.
If L L L represents all six permutations of 3 4 5, the number of Pick3 combinations for each category can be computed by the following formula in D1 and copied down through D27:
=PERMUT(3,COUNTIF(A1:C1,"L"))*PERMUT(3,COUNTIF(A1:C1,"H"))*PERMUT(4,COUNTIF(A1:C1,"M"))
In that case, SUM(D1:D27) is indeed 720. But the number of Pick3 combinations represented by L L L is 6; so the probability is 6/720, which is about 0.83%.
On the other hand, if L L L represents just one combination (3 4 5), the number Pick3 combinations for each category is computed by the following formula in F1 and copied down through F27:
=COMBIN(3,COUNTIF(A1:C1,"L"))*COMBIN(3,COUNTIF(A1:C1,"H"))*COMBIN(4,COUNTIF(A1:C1,"M"))
In that case, SUM(F1:F27) is 456(!). And the probability of L L L is 1/456, which is about 0.22%.
Note that SUM(F1:F27) is 456, not 120. This is because if we only consider __combinations__ in each category, your methodology is a __mix__ of combinations and permutations. For example, L L M and M L L are simply permutations of each other.
For that reason, the latter case does not make sense to do, IMHO.
The following macro generates a table similar to yours with all the permutations in each category. The total represents all 720 Pick3 permutations without replacement (i.e. no repeats).
-----
Option Explicit
Sub genPermut()
Dim v(1 To 27, 1 To 3 + 2 + 36) As Variant
Dim b1 As Variant, b2 As Variant, b3 As Variant
Dim n1 As Variant, n2 As Variant, n3 As Variant
Dim n1Array As Variant, n2Array As Variant, n3Array As Variant
Dim r As Long, c As Long, totl As Long, i As Long
ActiveSheet.Cells.Clear
r = 0: totl = 0
For Each b1 In Array("L", "M", "H")
n1Array = IIf(b1 = "H", Array(0, 1, 2), _
IIf(b1 = "L", Array(3, 4, 5), Array(6, 7, 8, 9)))
For Each b2 In Array("L", "M", "H")
n2Array = IIf(b2 = "H", Array(0, 1, 2), _
IIf(b2 = "L", Array(3, 4, 5), Array(6, 7, 8, 9)))
For Each b3 In Array("L", "M", "H")
n3Array = IIf(b3 = "H", Array(0, 1, 2), _
IIf(b3 = "L", Array(3, 4, 5), Array(6, 7, 8, 9)))
r = r + 1
v(r, 1) = b1: v(r, 2) = b2: v(r, 3) = b3
' skip 2 columns for count in category and for probability
c = 5
For Each n1 In n1Array
For Each n2 In n2Array
For Each n3 In n3Array
If n1 <> n2 And n1 <> n3 And n2 <> n3 Then
c = c + 1
v(r, c) = --(n1 & n2 & n3)
End If
Next n3, n2, n1
v(r, 4) = c - 5 ' count in category
totl = totl + v(r, 4)
Next b3, b2, b1
For i = 1 To r
v(i, 5) = v(i, 4) / totl ' probability
Next
Range("a1").Resize(r, UBound(v, 2)).Value = v
Range("e1").Resize(r).NumberFormat = "0.00%"
Range("f1").Resize(r, 36).NumberFormat = "000"
End Sub