Sub Principale()
' mapomme - XLD
Dim t, tCombins, tvals, k&, tLesTirages, i&, tcombinPN, j&, s$, n&, ts, debut
debut = Timer
With Sheets("Stat")
.Range("a1").CurrentRegion.Clear
' liste des combinaisons de 3 parmi 1,2,3,4,5,...,87,688,89,90
Application.StatusBar = "Liste de toutes les combinaisons 3 parmi 90"
tCombins = TableauCombiPparmiN(3, 90) 'Sub o function non definita
' transformer les combinaisons en nombre
For i = 1 To UBound(tCombins): tCombins(i, 1) = CLng(Format(tCombins(i, 1), "00") & Format(tCombins(i, 2), "00") & _
Format(tCombins(i, 3), "00")): Next
ReDim Preserve tCombins(1 To UBound(tCombins), 1 To 1)
' écriture sur la feuille
.Range("a1") = "Combinaisons": .Range("b1") = "nn1": .Range("c1") = "nn2"
.Range("d1") = "nn3": .Range("e1") = "Occurence"
.Range("f1") = "Ecart/dernier tirage"
.Range("a2").Resize(UBound(tCombins)) = tCombins
'tableau des valeurs et écarts
ReDim tvals(1 To UBound(tCombins), 1 To 1)
ReDim tecarts(1 To UBound(tCombins), 1 To 1)
End With
' lecture des tirages et des dates
Application.StatusBar = "trie et lecture des tirages"
With Sheets("Tirages")
.Range("a1").CurrentRegion.Sort key1:=.Range("a1"), order1:=xlDescending, MatchCase:=False, Header:=xlYes
k = .Cells(Rows.Count, "a").End(xlUp).Row
tLesTirages = .Range("b2:f" & k)
End With
tcombinPN = TableauCombiPparmiN(3, 5) 'les combinaisons de 4 parmi 1,2,3,4,5,...,17,18,19,20
Application.ScreenUpdating = True
For i = 1 To UBound(tLesTirages)
If (i Mod 100) = 0 Then Application.StatusBar = "Tirage n° " & Format(i, "# ##0") & " / " & Format(UBound(tLesTirages), "# ##0")
For k = 1 To UBound(tcombinPN)
s = ""
For j = 1 To UBound(tcombinPN, 2): s = s & Format(tLesTirages(i, tcombinPN(k, j)), "00"): Next j
n = DichoTablo(tCombins, CLng(s))
tvals(n, 1) = tvals(n, 1) + 1 'PER ADESSO SI FERMA QUI ERRORE DI RUN TIME 9 'INDICE NON INCLUSO NELL'INTERVALLLLO
If tecarts(n, 1) = "" Then tecarts(n, 1) = i - 1
Next k
Next i
' tableau pour afficher les résultats
Application.StatusBar = "Construction tableau des résulats pour affichage"
ReDim Preserve tCombins(1 To UBound(tCombins), 1 To 6)
For i = 1 To UBound(tCombins)
s = tCombins(i, 1): If Len(s) = 6 Then s = "0" & s
For j = 1 To 4
tCombins(i, j + 1) = Mid(s, 1 + 2 * (j - 1), 2): Next
tCombins(i, 5) = tvals(i, 1)
tCombins(i, 6) = tecarts(i, 1)
Next i
' affichage et formatage
Application.StatusBar = "affichage et formatage"
Application.ScreenUpdating = False
With Sheets("Stat")
.Columns(2).Resize(, 3).NumberFormat = "00"
.Range("a2").Resize(UBound(tCombins), UBound(tCombins, 2)) = tCombins
.Range("a1").CurrentRegion.AutoFilter
.Range("a1").CurrentRegion.Borders.LineStyle = xlDash
.Range("a1").Resize(, UBound(tCombins, 2)).EntireColumn.AutoFit
.Range("a1").CurrentRegion.Columns(1).Interior.Color = RGB(220, 220, 220)
.Range("a1").CurrentRegion.Columns(2).Resize(, 3).Interior.Color = RGB(240, 240, 240)
.Range("a1").Resize(, 6).Interior.Color = RGB(220, 220, 255)
Application.Goto .Range("a1"), True
End With
Application.StatusBar = False
Application.ScreenUpdating = True
MsgBox Format(Timer - debut, "0.0\ sec.")
End Sub
| | | | | | | | | | | | | |