Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range, t, n%, nn&
Set r = Intersect(Target, [A:A], UsedRange)
If r Is Nothing Then Exit Sub
If r.Count > 9999 Then t = Timer 'mesure de la durée à partir de 10000 cellules
Application.ScreenUpdating = False
r.NumberFormat = "General" 'RAZ
With Range(Replace(r.Address, ",", ":"))
.Columns(2).Resize(, 2).Insert xlToRight '2 colonnes auxiliaires
With .Columns(2)
.Cells(1, 2) = 1: .Columns(2).DataSeries 'repérage du classement
.FormulaR1C1 = "=IF(ISNUMBER(RC[-1]),IF(NOT(MOD(RC[-1],1)),LEN(RC[-1])))"
.Value = .Value 'supprime les formules
.EntireRow.Sort .Columns(1) 'tri pour regrouper et accélérer
For n = 4 To Application.Max(.Value)
nn = Application.CountIf(.Cells, n)
If nn Then
Set r = .Cells(Application.Match(n, .Cells, 0), 0).Resize(nn)
r.NumberFormat = Application.Rept("000\ ", Int(n / 3)) & String(n - 3 * Int(n / 3), "0")
End If
Next
.EntireRow.Sort .Columns(2), xlAscending, Header:=xlNo 'ordre initial
.Resize(, 2).Delete xlToLeft
End With
End With
If t Then Application.ScreenUpdating = True: MsgBox "Durée " & Format(Timer - t, "0.00 \s")
End Sub