Sub FiltrerRapport()
Const CodeES = "042U402"
Const WshSNom = "Rapport 1"
Const WshCNom = "Données filtrées"
Const LoNom = "TS_Rapport"
Dim wshS As Worksheet, wshC As Worksheet
Dim LO As ListObject
Set wshS = ThisWorkbook.Worksheets(WshSNom)
Set wshC = ThisWorkbook.Worksheets(WshCNom)
Application.ScreenUpdating = False
On Error Resume Next
With wshC.Evaluate(LoNom)
.Clear
Application.DisplayAlerts = False
.ListObject.Unlist
Application.DisplayAlerts = True
End With
On Error GoTo 0
Set C = wshS.Cells.Find(What:="N° Individu", After:=wshS.Cells(1), LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).CurrentRegion
C.Copy Destination:=wshC.[Titres].Resize(C.Rows.Count)
Set LO = wshC.ListObjects.Add(xlSrcRange, wshC.[Titres].CurrentRegion, , xlYes)
With LO
.Name = "TS_Rapport"
.TableStyle = ""
.ListColumns.Add.Name = "Test"
End With
With wshC.[TS_Rapport[Test]]
.NumberFormat = "General"
.FormulaR1C1 = "=(COUNTIFS([N° Individu],TS_Rapport[[#This Row],[N° Individu]],[N° Immatriculation],TS_Rapport[[#This Row],[N° Immatriculation]])>1)*(TS_Rapport[[#This Row],[ES Réparateur AT]]=""042U402"")"
LO.Range.AutoFilter Field:=LO.ListColumns("Test").Index, Criteria1:=0
wshC.[TS_Rapport[Test]].EntireRow.Delete
LO.Range.AutoFilter Field:=LO.ListColumns("Test").Index
LO.ListColumns("Test").Delete
End With
With wshC.[TS_Rapport]
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.RowHeight = 20
End With
Application.ScreenUpdating = True
End Sub