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 62 63 64 65 66 67 68 69 70
|
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 10.08.2010 by fd151
'
' Keyboard Shortcut: Ctrl+a
'
Cells.Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("C1") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
Racine = InputBox("Indiquer la racine à traiter (sanstiret) ", "RACINE")
DatesDebutFin = InputBox("Indiquer les années à considérer ", "ANNEES")
If DatesDebutFin = "" Then
DDebut = 1900
DFin = 2100
Else
DDebut = Int(Left(DatesDebutFin, 4))
DFin = Int(Right(DatesDebutFin, 4))
End If
Sheets("Travail").Select
'Elimination des lignes inutiles
Cpt = 0
Range("A1").Select
Do Until ActiveCell.Offset(1, 0).Value = "" And ActiveCell.Offset(2, 0).Value = ""
ZoneRacine = (Mid(ActiveCell.Value, 12, 3) & Mid(ActiveCell.Value, 16, 3))
If ZoneRacine = Racine Then
ZoneAnnee = Year(ActiveCell.Offset(0, 2))
If (ZoneAnnee >= DDebut And ZoneAnnee <= DFin) Then
ActiveCell.Offset(0, 13).FormulaR1C1 = "= YEAR(RC[-11])"
ActiveCell.Offset(1, 0).Select
Cpt = Cpt + 1
Else
ActiveCell.EntireRow.Delete
End If
Else
ActiveCell.EntireRow.Delete
End If
Loop
ActiveCell.EntireRow.Delete
'sortie avec message si rien dans le fichier
If Cpt = 0 Then
MsgBox "pas de racine "
Exit Sub
End If |
Partager