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 50 51 52 53 54 55 56 57 58 59 60 61
| Sub Creerfeuille_reseauencourstarife2015()
Sheets("en cours liste complète réseau").Activate
'dte = Year(Date)
'mt = Month(Date) - 1
' Dim debut As Long, fin As Long
' debut = DateSerial(dte, 1, 1)
' fin = DateSerial(dte, mt, 30)
Dim ListeTitre()
Dim ListeParam()
Dim DateDebut As Date
Dim DateFin As Date
DateDebut = "01/01/" & Year(Date)
DateFin = "01/" & Month(Date) & "/" & Year(Date)
ListeTitre = Array("Code_Delegation", "Statut_Etude", "Date_1ereTarification")
ListeParam = Array("<>DGEN*", Array("3", "4", "5", "6"))
If Month(Now()) = 1 Then
For i = LBound(ListeTitre) To UBound(ListeTitre)
Set c = Nothing
Set c = Rows(1).Find(ListeTitre(i), , xlValues, xlWhole)
If Not c Is Nothing Then
If i <= UBound(ListeParam) Then
Range("A1").AutoFilter c.Column, ListeParam(i), xlFilterValues
Else
Range("A1").AutoFilter c.Column, xlFilterLastYear, xlFilterDynamic
End If
End If
Next i
' on boucle sur chaque colonne cherchée
' et on filtre sur son paramètre dédié
Else
For i = LBound(ListeTitre) To UBound(ListeTitre)
Set c = Nothing
Set c = Rows(1).Find(ListeTitre(i), , xlValues, xlWhole)
If Not c Is Nothing Then
If i <= UBound(ListeParam) Then
Range("A1").AutoFilter c.Column, ListeParam(i), xlFilterValues
Else
Range("A1").AutoFilter c.Column, ">=" & DateDebut, xlAnd, "<" & Format(DateFin, "mm/dd/yyyy")
End If
End If
Next i
End If
Range(Range("A1"), Range("A1").SpecialCells(xlLastCell)).Copy
Sheets.Add After:=Sheets("en cours liste complète réseau")
ActiveSheet.Name = "réseau en cours tarifé 2015"
ActiveSheet.Paste
Application.CutCopyMode = False
Sheets("en cours liste complète réseau").Select
Selection.AutoFilter
End Sub |
Partager