Dim d As Object 'mémorise la variable
Sub Calcul_K_L()
Dim c As Range
Set d = CreateObject("Scripting.Dictionary")
'---liste sans doublon---
For Each c In [P3:P92]
If c <> "" Then d(c.Value) = ""
Next
'---traitement des plages---
With Sheets("Grilles").[K3:K43200] 'à adapter
.ClearContents 'RAZ
.Formula = "=IF(J3="""","""",K(A1:I3))"
.Value = .Value 'supprime les formules
End With
With Sheets("Grilles").[L3:L43200] 'à adapter
.ClearContents 'RAZ
.Formula = "=IF(J3="""","""",L(A1:I3))"
.Value = .Value 'supprime les formules
End With
End Sub
Function K(r As Range) As String
Dim tablo, i, n, j
tablo = r 'matrice, plus rapide
For i = 1 To 3
n = 0
For j = 1 To 9
If d.exists(tablo(i, j)) Then n = n + 1
Next j
If n <> 5 Then Exit Function
Next i
K = "QUINE"
End Function
Function L(r As Range) As String
Dim tablo, i, n, j, nn
tablo = r 'matrice, plus rapide
For i = 1 To 3
n = 0
For j = 1 To 9
If d.exists(tablo(i, j)) Then n = n + 1
Next j
If n = 5 Then nn = nn + 1
Next i
If nn = 3 Then L = "CARTON PLEIN" Else If nn = 2 Then L = "DOUBLE QUINE"
End Function