Sub Remplissage()
Dim i As Long, Nb As Long, j as long
Application.ScreenUpdating = False
Range("U2:AE1001").ClearContents
Range("AD2:AD1001").FormulaR1C1 = "=IF(SUMPRODUCT(COUNTIF(RC[-9]:RC[-1],R1C[5]:R1C[19]))>2,1,0)"
For i = 2 To 1001
Nb = 1
Recommence:
Do
Range(Cells(i, "U"), Cells(i, "AC")).FormulaR1C1 = "=RANDBETWEEN(1,100)"
Range(Cells(i, "U"), Cells(i, "AC")).Value = Range(Cells(i, "U"), Cells(i, "AC")).Value
For j = 22 To 29
If Application.CountIf(Range(Cells(i, "U"), Cells(i, "AC")), Cells(i, j)) > 1 Then
Nb = Nb + 1
GoTo Recommence
End If
Next j
Loop While Cells(i, "AD") <> 1
Cells(i, "AE") = Nb
Next i
End Sub