1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| 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:=10, 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
With Sheets("Bases Donnée Démographique")
dl1 = .Range("A" & .Rows.Count).End(xlUp).Row
Set pl1 = .Range("B1:I" & dl)
.Range("A3").AutoFilter field:=10, Criteria1:=Sheets("Fiche Secteur").[K2] 'Filtre le tableau par rapport au secteur
nl1 = Range("A3:A" & .Range("A65536").End(xlUp).Row).SpecialCells(12).Count
pl1.SpecialCells(12).Copy Range("A40") 'Copie le tableau filtré
End With
With Sheets("Bases Résultat 2013")
dl2 = .Range("A" & .Rows.Count).End(xlUp).Row
Set pl2 = .Range("C1:J" & dl)
.Range("A3").AutoFilter field:=1, Criteria1:=Sheets("Fiche Secteur").[K2] 'Filtre le tableau par rapport au secteur
nl2 = Range("A3:A" & .Range("A65536").End(xlUp).Row).SpecialCells(12).Count
pl2.SpecialCells(12).Copy Range("A75") 'Copie le tableau filtré
test = fasle
Application.ScreenUpdating = True
End With
With Sheets("Bases Résultat 2012")
dl3 = .Range("A" & .Rows.Count).End(xlUp).Row
Set pl3 = .Range("C1:J" & dl)
.Range("A3").AutoFilter field:=1, Criteria1:=Sheets("Fiche Secteur").[K2] 'Filtre le tableau par rapport au secteur
nl3 = Range("A3:A" & .Range("A65536").End(xlUp).Row).SpecialCells(12).Count
pl3.SpecialCells(12).Copy Range("A108") 'Copie le tableau filtré
test = fasle
Application.ScreenUpdating = True
End With
End Sub |
Partager