Sub Tirages()
Dim TDon(), TNoms() As String, TRésu(), M As Long, L As Integer, C As Integer, LMax As Long, MMax As Long, J As Long, LOt As ListObject
'---------------------------------------------
Dim tStart As Currency, tEnd As Currency, freq As Currency, Delta
'----------------------------------------------
' Récupération des inscrits
Set LOt = [TbTour1].ListObject
If PreserverAncienTirage(LOt, Action:="un autre tirage", Source:="Tirages") Then Exit Sub
'---------------------------------------------
'init perf counter
QueryPerformanceFrequency freq
QueryPerformanceCounter tStart
'---------------------------------------------
ImageRoueTourne
TDon = LOt.DataBodyRange.Value
ReDim TNoms(1 To UBound(TDon, 1))
For L = 1 To UBound(TDon, 1)
TNoms(L) = TDon(L, 2)
If TNoms(L) = "" Then
If MsgBox("Nom de l'équipe " & L & " manquant." _
& vbLf & "Faut-il poursuivre en ignorant les données à partir de là ?", _
vbYesNo, "Tirages") = vbYes Then
ReDim Preserve TNoms(1 To L - 1): Exit For
Else: Exit Sub: End If
End If
Next L
' Tirage
If Tirage1vs1OK(NbJrs:=UBound(TNoms), Manches:=2) Then
Rem. ——— Versement du tableau Tirage vers les tableaux Excel
MMax = UBound(Tirage, 1) ' Nombre de tours
LMax = UBound(Tirage, 2) ' Nombre de lignes de rencontres.
ReDim TRésu(1 To LMax * 2, 1 To 2)
For M = 1 To MMax
For L = 1 To LMax
For C = 1 To 2
J = Tirage(M, L, C)
If J <> 0 Then
TRésu(2 * (L - 1) + C, 1) = J: TRésu(2 * (L - 1) + C, 2) = TNoms(J)
Else
TRésu(2 * (L - 1) + C, 1) = Empty: TRésu(2 * (L - 1) + C, 2) = Empty
End If: Next C, L
'ici normalement on a fini la matrice vba du tableau
'on capture avant retranscription
'-----------------------------------------------------------------------
QueryPerformanceCounter tEnd
Delta = (tEnd - tStart) / freq ' secondes
MsgBox "Temps d'execution: " & _
Format$(Delta, "0.000000000") & " sec" & vbCrLf & _
Format$(Delta * 1000, "0.000000") & " millisecondes" & vbCrLf & _
Format$(Delta * 1000000, "0.000") & " microsecondes" & vbCrLf & _
Format$(Delta * 1000000000, "#0") & " nanosecondes"
'-----------------------------------------------------------------------
Set LOt = Evaluate("TbTour" & M).ListObject
If LOt.ListRows.Count > 0 Then LOt.DataBodyRange.Delete xlShiftUp
LOt.HeaderRowRange.Offset(1).Resize(UBound(TRésu, 1), 2) = TRésu
L = LOt.HeaderRowRange.Row
LOt.ListColumns(3).DataBodyRange.Formula = "=IF(MOD(ROW()-" & L & ",2),(ROW()-" & L - 1 & ")/2,"""")"
Next M
End If
ImageRoueFixe
ActiveSheet.[A1].Select
End Sub