Sub Manquants()
Dim F As Worksheet, tablo, resu&(), i&, deb&, manque&, j&, n&
Set F = Feuil1 'CodeName de la feuille, à adapter
If F.FilterMode Then F.ShowAllData 'si la feuille est filtrée
tablo = F.[A1].CurrentRegion.Resize(, 2) 'matrice, plus rapide, au moins 2 éléments
tri tablo, 1, UBound(tablo)
ReDim resu(1 To Rows.Count, 1 To 1)
For i = 2 To UBound(tablo) - 1
deb = tablo(i - 1, 1)
manque = tablo(i, 1) - deb - 1
For j = 1 To manque
n = n + 1
resu(n, 1) = deb + j
Next j, i
'---restitution---
With F.[B2] '1ère cellule de restitution, à adapter
If n Then .Resize(n) = resu
.Offset(n).Resize(F.Rows.Count - n - .Row + 1).ClearContents 'RAZ en dessous
End With
With F.UsedRange: End With 'actualise la barre de défilement verticale
End Sub
Sub tri(a, gauc, droi) ' Quick sort
Dim ref, g, d, temp
ref = a((gauc + droi) \ 2, 1)
g = gauc: d = droi
Do
Do While a(g, 1) < ref: g = g + 1: Loop
Do While ref < a(d, 1): d = d - 1: Loop
If g <= d Then
temp = a(g, 1): a(g, 1) = a(d, 1): a(d, 1) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call tri(a, g, droi)
If gauc < d Then Call tri(a, gauc, d)
End Sub