Sub Test_Filter_and_Delete()
Delete_Table "Nb Jours", 5
Delete_Table 20, 4
Delete_Table 30, "DOUBLONS"
End Sub
Function Delete_Table(Field, Criteria) As Integer
Dim Col_Index As Integer
Application.DisplayAlerts = False
With [Tableau_Indicateurs_Achats.accdb106]
Select Case True
Case Not IsNumeric(Field)
On Error Resume Next
Col_Index = .ListObject.ListColumns(Field).Index
On Error GoTo 0
Case Field <= 0: Col_Index = Field
Case Field > .Columns.Count: Col_Index = 0
Case Else: Col_Index = Field
End Select
If Col_Index > 0 Then
.AutoFilter Field:=Col_Index, Criteria1:=Criteria
N = Application.Subtotal(3, .Columns(Col_Index))
If N > 0 Then
' .Delete
MsgBox N & " lignes supprimées"
End If
.AutoFilter Field:=Col_Index
End If
End With
Application.DisplayAlerts = True
Delete_Table = N
End Function