Option Explicit
Sub CallCombin2()
'sub exemple
Call Combin2(17, 5)
End Sub
Sub Combin2(a As Byte, b As Byte)
'Liste sur une nouvelle feuille, en colonnes, toutes les combinaisons des deux entrées
'a >= b
Dim oWs As Worksheet, i As Long, cb As Long
Sheets.Add
Set oWs = ActiveSheet
cb = WorksheetFunction.Combin(a, b)
If b > a Then Exit Sub
If WorksheetFunction.Combin(a, b) > Columns.Count Then Exit Sub
For i = 1 To b
oWs.Cells(1, i) = i
Next i
For i = 1 To b
Select Case i
Case b
oWs.Cells(2, i).FormulaR1C1 = "=IF(R[-1]C=" & a & ",RC[-1]+1,R[-1]C+1)"
Case 1
oWs.Cells(2, i).FormulaR1C1 = "=IF(R[-1]C[1]=" & (a - b + 2) & ",R[-1]C+1,R[-1]C)"
Case Else
oWs.Cells(2, i).FormulaR1C1 = "=IF(R[-1]C[1]=" & (a - b + 1 + i) & ",IF(R[-1]C=" & (a - b + i) & ",RC[-1]+1,R[-1]C+1),R[-1]C)"
End Select
Next i
oWs.Range(oWs.Cells(2, 1), oWs.Cells(2, b)).Copy Destination:=oWs.Range(oWs.Cells(2, 1), oWs.Cells(cb, b))
oWs.Range(oWs.Cells(2, 1), oWs.Cells(cb, b)).Copy
oWs.Range(oWs.Cells(2, 1), oWs.Cells(cb, b)).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
Set oWs = Nothing
End Sub