1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Private Sub worksheet_Change(ByVal target As Range)
'Déclaration des variables
Dim pl As Range, derl&, nl&, dl&
If target.Address <> "$K$2" Then Exit Sub
Application.ScreenUpdating = False
test = True
Rows(3).Resize(1000).Clear
With Sheets("Bases Communes")
dl = .Range("A" & .Rows.Count).End(xlUp).Row
Set pl = .Range("A1:H" & dl)
.Range("A3").AutoFilter Field:=9, Criteria1:=Sheets("Fiche Secteur").[K2] 'Filtre le tableau par rapport au secteur
nl = Range("A3:A" & .Range("A65536").End(xlUp).Row).SpecialCells(12).Count
pl.SpecialCells(12).Copy Range("A4") 'Copie le tableau filtré
.Range("A3").AutoFilter 'suprime le filtre
End With
test = fasle
Application.ScreenUpdating = True
End Sub |
Partager