1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
| Option Explicit
Option Base 1
Sub Macro_Atester()
Dim Ligne As Long, Indice As Long
'efface la BdD Y:AR
Worksheets("Feuil1").Select
'For Ligne = 2 To Range("BN" & Rows.Count).End(xlUp).Row
Range("Y2:AR3012").ClearContents
'ajoute 2eme couplé col BN:BO a U1:V1
' Range("U1:V1").Value = Range("BN" & Ligne & ":BO" & Ligne).Value
Calculate
'extraire les lignes de A:T a Y2
Dim I&, fin&, aa, bb, y&, a&
With Feuil1
fin = .Range("A" & Rows.Count).End(xlUp).Row
aa = .Range("A2:W" & fin)
End With
y = 1
ReDim bb(UBound(aa, 2), y)
For I = 1 To UBound(aa) - 1
If aa(I + 1, 22) = 1 Then
ReDim Preserve bb(UBound(aa, 2), y)
For a = 1 To UBound(aa, 2) - 3
bb(a, y) = aa(I, a)
Next a
y = y + 1
End If
Next I
Range("Y2").Resize(UBound(bb, 2), UBound(bb)) = Application.Transpose(bb)
'Combinaison
Dim D As Integer, K As Integer, L As Integer, M As Integer
Dim NbMax As Integer
Dim Tablo(1 To 70, 1 To 70, 1 To 70, 1 To 70) As Integer
Dim J As Long
Dim Resultat(1 To 1, 1 To 5)
Dim Tbl1
Dim Nombre As Integer
Application.ScreenUpdating = False
Tbl1 = Range("Feuil1!Ktir")
NbMax = UBound(Tbl1, 2)
For J = 1 To UBound(Tbl1)
For D = 1 To NbMax - 3
For K = D + 1 To NbMax - 2
For L = K + 1 To NbMax - 1
For M = L + 1 To NbMax
Tablo(Tbl1(J, D), Tbl1(J, K), Tbl1(J, L), Tbl1(J, M)) = Tablo(Tbl1(J, D), Tbl1(J, K), Tbl1(J, L), Tbl1(J, M)) + 1
Next M
Next L
Next K
Next D
Next J
Range("AW2:BG" & Rows.Count).ClearContents
Indice = 0
For D = 1 To 70
For K = 1 To 70
For L = 1 To 70
For M = 1 To 70
If Tablo(D, K, L, M) > 0 Then
Indice = Indice + 1
Resultat(1, 1) = D
Resultat(1, 2) = K
Resultat(1, 3) = L
Resultat(1, 4) = M
Resultat(1, 5) = Tablo(D, K, L, M)
Cells(1 + Indice, "AW").Resize(1, 5) = Resultat
End If
'End If
Next M
Next L
Next K
Next D
Range("AW2:BA" & Indice + 1).Copy
Range("BC2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
With ActiveSheet.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("BG2:BG" & Indice + 1), SortOn:=xlSortOnValues, _
Order:=xlDescending, DataOption:=xlSortNormal
.SetRange Range("BC2:BG" & Indice + 1)
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'tri BC:BF
For J = 2 To 23
Range("BC" & J).Resize(1, 4).Copy
Cells(2 + ((J - 2) * 4), "BJ").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
Next J
'fin tri BC:BF
Range("$BJ$2:$BJ$89").RemoveDuplicates Columns:=1, Header:=xlNo
'colonne BJ rangée en BP
Dim vLigne As Long
vLigne = Range("BP65536").End(xlUp).Row + 1
If vLigne < 2 Then vLigne = 2
Range("BJ2:BJ26").Copy
Range("BP" & vLigne).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=True
Range("AT1").Select
'Next Ligne
Range("Y2:AR3012").ClearContents
Range("AW2:BG" & Rows.Count).ClearContents
Application.CutCopyMode = False
End Sub |
Partager