Option Explicit
Dim n1&, lg2&
Private Sub Job(col As Byte)
Dim lg1&, i&
With Worksheets("Feuil1")
For i = 1 To n1
lg1 = i + 5
With .Cells(lg1, col)
If .Value > 0 Then Cells(lg2, 1) = .Value: lg2 = lg2 + 1
End With
Next i
End With
End Sub
Sub Essai()
If ActiveSheet.Name <> "Feuil2" Then Exit Sub
With Worksheets("Feuil1")
n1 = .ListObjects("Tableau1").ListRows.Count
If n1 = 0 Then Exit Sub 'y'a aucune donnée à copier
Dim n2&: Application.ScreenUpdating = 0
With ActiveSheet.ListObjects("Tableau2")
If Not IsEmpty(.DataBodyRange) Then n2 = .ListRows.Count
lg2 = n2 + 4: Job 3: Job 4
With .Sort.SortFields
.Clear: .Add Key:=Range("Tableau2[[#All],[Comptes]]"), _
SortOn:=xlSortOnValues, Order:=xlAscending
.Parent.Apply
End With
End With
End With
ActiveCell.Select
End Sub