1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Sub Filtre()
Dim DerLig_f1 As Long, DerLig_f2 As Long, DerCol_f2 As Long
Application.ScreenUpdating = False
Set f1 = Sheets("BDD")
Set f2 = Sheets("Filtre")
f2.Cells.Clear
DerLig_f1 = f1.[N100000].End(xlUp).Row
If f1.AutoFilterMode = False Then f1.Rows(1).AutoFilter
f1.Range("A1:Y" & DerLig_f1).AutoFilter Field:=21, Criteria1:="NOK"
NbCol = f1.[IV1].End(xlToLeft).Column
f1.Range(Cells(1, "N"), Cells(DerLig_f1, "N")).SpecialCells(xlCellTypeVisible).Copy Destination:=f2.[A1]
f1.Range(Cells(1, "U"), Cells(DerLig_f1, "U")).SpecialCells(xlCellTypeVisible).Copy Destination:=f2.[B1]
f1.Range(Cells(1, "Y"), Cells(DerLig_f1, "Y")).SpecialCells(xlCellTypeVisible).Copy Destination:=f2.[C1]
DerLig_f2 = f2.[A100000].End(xlUp).Row
f1.AutoFilterMode = False
f1.Range("A1:Y" & DerLig_f1).AutoFilter Field:=25, Criteria1:="NOK"
f1.Range(Cells(2, "N"), Cells(DerLig_f1, "N")).SpecialCells(xlVisible).Copy Destination:=f2.Cells(DerLig_f2 + 1, "A")
f1.Range(Cells(2, "U"), Cells(DerLig_f1, "U")).SpecialCells(xlVisible).Copy Destination:=f2.Cells(DerLig_f2 + 1, "B")
f1.Range(Cells(2, "Y"), Cells(DerLig_f1, "Y")).SpecialCells(xlVisible).Copy Destination:=f2.Cells(DerLig_f2 + 1, "C")
f1.AutoFilterMode = False
f2.Select
Set f1 = Nothing
Set f2 = Nothing
End Sub |
Partager