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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
| Sub TEST()
Application.ScreenUpdating = False
If Worksheets.Count = 1 Then
Sheets.Add After:=ActiveSheet
ActiveSheet.Name = "5eme feuille"
With Sheets("5eme feuille")
.Range("A1").FormulaR1C1 = "Titre1"
.Range("B1").FormulaR1C1 = "Titre2"
.Range("C1").FormulaR1C1 = "Titre3"
.Range("D1").FormulaR1C1 = "Titre4"
.Range("E1").FormulaR1C1 = "Titre5"
.Range("F1").FormulaR1C1 = "Titre6"
.Range("G1").FormulaR1C1 = "Titre7"
.Range("H1").FormulaR1C1 = "Titre8"
End With
Sheets("Report").Range(Sheets("Report").Range("B2"), Sheets("Report").Range("B2").End(xlDown)).Copy Destination:=Sheets("5eme feuille").Range("A2")
Range("B2:B" & Range("A" & Rows.Count).End(xlUp).Row) = 2016
Sheets("Report").Range(Sheets("Report").Range("C2"), Sheets("Report").Range("C2").End(xlDown)).Copy Destination:=Sheets("5eme feuille").Range("C2")
Sheets.Add After:=Sheets("Report")
ActiveSheet.Name = "4eme feuille"
With Sheets("Report").Range("A1").CurrentRegion
.AutoFilter Field:=5, Criteria1:="7"
.Copy Destination:=Sheets("4eme feuille").Range("A1")
End With
Application.CutCopyMode = False
With Sheets("4eme feuille").Columns("A:A")
.FormatConditions.AddUniqueValues
.FormatConditions(Sheets("4eme feuille").Columns("A:A").FormatConditions.Count).SetFirstPriority
.FormatConditions(1).DupeUnique = xlDuplicate
End With
With Sheets("4eme feuille").Columns("A:A").FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Sheets("4eme feuille").Columns("A:A").FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
With Sheets("4eme feuille")
.Columns("A:A").FormatConditions(1).StopIfTrue = False
'.Range("A1").CurrentRegion.AutoFilter Field:=1, Criteria1:=RGB(255, _
199, 206), Operator:=xlFilterCellColor
End With
Sheets.Add After:=Sheets("Report")
ActiveSheet.Name = "3eme feuille"
With Sheets("Report").Range("A1").CurrentRegion
.AutoFilter Field:=5, Criteria1:="9"
.Copy Destination:=Sheets("3eme feuille").Range("A1")
End With
Application.CutCopyMode = False
With Sheets("3eme feuille").Columns("A:A")
.FormatConditions.AddUniqueValues
.FormatConditions(Sheets("3eme feuille").Columns("A:A").FormatConditions.Count).SetFirstPriority
.FormatConditions(1).DupeUnique = xlDuplicate
End With
With Sheets("3eme feuille").Columns("A:A").FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Sheets("3eme feuille").Columns("A:A").FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
With Sheets("3eme feuille")
.Columns("A:A").FormatConditions(1).StopIfTrue = False
'.Range("A1").CurrentRegion.AutoFilter Field:=1, Criteria1:=RGB(255, _
199, 206), Operator:=xlFilterCellColor
End With
Sheets.Add After:=Sheets("Report")
ActiveSheet.Name = "2nd Feuille"
With Sheets("Report").Range("A1").CurrentRegion
.AutoFilter Field:=5, Criteria1:="14"
.Copy Destination:=Sheets("2nd Feuille").Range("A1")
End With
Application.CutCopyMode = False
With Sheets("2nd Feuille").Columns("A:A")
.FormatConditions.AddUniqueValues
.FormatConditions(Sheets("2nd Feuille").Columns("A:A").FormatConditions.Count).SetFirstPriority
.FormatConditions(1).DupeUnique = xlDuplicate
End With
With Sheets("2nd Feuille").Columns("A:A").FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Sheets("2nd Feuille").Columns("A:A").FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
With Sheets("2nd Feuille")
.Columns("A:A").FormatConditions(1).StopIfTrue = False
' .Range("A1").CurrentRegion.AutoFilter Field:=1, Criteria1:=RGB(255, _
199, 206), Operator:=xlFilterCellColor
End With
Sheets.Add After:=Sheets("Report")
ActiveSheet.Name = "1ere feuille"
With Sheets("Report").Range("A1").CurrentRegion
.AutoFilter Field:=5, Criteria1:="23"
.Copy Destination:=Sheets("1ere feuille").Range("A1")
End With
Application.CutCopyMode = False
With Sheets("1ere feuille").Columns("A:A")
.FormatConditions.AddUniqueValues
.FormatConditions(Sheets("1ere feuille").Columns("A:A").FormatConditions.Count).SetFirstPriority
.FormatConditions(1).DupeUnique = xlDuplicate
End With
With Sheets("1ere feuille").Columns("A:A").FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Sheets("1ere feuille").Columns("A:A").FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
With Sheets("1ere feuille")
.Columns("A:A").FormatConditions(1).StopIfTrue = False
' .Range("A1").CurrentRegion.AutoFilter Field:=1, Criteria1:=RGB(255, _
199, 206), Operator:=xlFilterCellColor
End With
Sheets("1ere feuille").Range("A1").CurrentRegion.AutoFilter
Sheets("1ere feuille").AutoFilter.Sort.SortFields.Clear
Sheets("1ere feuille").AutoFilter.Sort.SortFields.Add(Range( _
"A1"), xlSortOnCellColor, xlAscending, , xlSortTextAsNumbers).SortOnValue. _
Color = RGB(255, 199, 206)
With ActiveWorkbook.Worksheets("1ere feuille").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
If Sheets("1ere feuille").Range("A2") = Sheets("1ere feuille").Range("A3") Then
If Sheets("1ere feuille").Range("H2").Value < Sheets("1ere feuille").Range("H3").Value Then
Sheets("1ere feuille").Rows(2).EntireRow.Delete x1Up
ElseIf Sheets("1ere feuille").Range("H2").Value > Sheets("1ere feuille").Range("H3").Value Then
Sheets("1ere feuille").Rows(3).EntireRow.Delete x1Up
End If
Else: Exit Sub
End If
Sheets("2nd Feuille").Range("A1").CurrentRegion.AutoFilter
Sheets("2nd Feuille").AutoFilter.Sort.SortFields.Clear
Sheets("2nd Feuille").AutoFilter.Sort.SortFields.Add(Range( _
"A1"), xlSortOnCellColor, xlAscending, , xlSortTextAsNumbers).SortOnValue. _
Color = RGB(255, 199, 206)
With ActiveWorkbook.Worksheets("2nd Feuille").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
If Sheets("2nd Feuille").Range("A2") = Sheets("2nd Feuille").Range("A3") Then
If Sheets("2nd Feuille").Range("H2").Value < Sheets("2nd Feuille").Range("H3").Value Then
Sheets("2nd Feuille").Rows(2).EntireRow.Delete x1Up
ElseIf Sheets("2nd Feuille").Range("H2").Value > Sheets("2nd Feuille").Range("H3").Value Then
Sheets("2nd Feuille").Rows(3).EntireRow.Delete x1Up
End If
Else: Exit Sub
End If
Sheets("3eme feuille").Range("A1").CurrentRegion.AutoFilter
Sheets("3eme feuille").AutoFilter.Sort.SortFields.Clear
Sheets("3eme feuille").AutoFilter.Sort.SortFields.Add(Range( _
"A1"), xlSortOnCellColor, xlAscending, , xlSortTextAsNumbers).SortOnValue. _
Color = RGB(255, 199, 206)
With ActiveWorkbook.Worksheets("3eme feuille").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
If Sheets("3eme feuille").Range("A2") = Sheets("3eme feuille").Range("A3") Then
If Sheets("3eme feuille").Range("H2").Value < Sheets("3eme feuille").Range("H3").Value Then
Sheets("3eme feuille").Rows(2).EntireRow.Delete x1Up
ElseIf Sheets("3eme feuille").Range("H2").Value > Sheets("3eme feuille").Range("H3").Value Then
Sheets("3eme feuille").Rows(3).EntireRow.Delete x1Up
End If
Else: Exit Sub
End If
Sheets("4eme feuille").Range("A1").CurrentRegion.AutoFilter
Sheets("4eme feuille").AutoFilter.Sort.SortFields.Clear
Sheets("4eme feuille").AutoFilter.Sort.SortFields.Add(Range( _
"A1"), xlSortOnCellColor, xlAscending, , xlSortTextAsNumbers).SortOnValue. _
Color = RGB(255, 199, 206)
With ActiveWorkbook.Worksheets("4eme feuille").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
If Sheets("4eme feuille").Range("A2") = Sheets("4eme feuille").Range("A3") Then
If Sheets("4eme feuille").Range("H2").Value < Sheets("4eme feuille").Range("H3").Value Then
Sheets("4eme feuille").Rows(2).EntireRow.Delete x1Up
ElseIf Sheets("4eme feuille").Range("H2").Value > Sheets("4eme feuille").Range("H3").Value Then
Sheets("4eme feuille").Rows(3).EntireRow.Delete x1Up
End If
Else: Exit Sub
End If
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
With Sheets("5eme feuille")
.Range("D2").FormulaR1C1 = "=VLOOKUP(RC[-3],'3eme feuille'!C2:C7,6,FALSE)"
.Range("D2").AutoFill Destination:=Sheets("5eme feuille").Range("D2:D" & Range("A1").End(xlDown).Row)
.Range("E2").FormulaR1C1 = "=VLOOKUP(RC[-4],'4eme feuille'!C2:C7,6,FALSE)"
.Range("E2").AutoFill Destination:=Sheets("5eme feuille").Range("E2:E" & Range("A1").End(xlDown).Row)
.Range("G2").FormulaR1C1 = "=VLOOKUP(RC[-6],'2nd Feuille'!C2:C7,6,FALSE)"
.Range("G2").AutoFill Destination:=Sheets("5eme feuille").Range("G2:G" & Range("A1").End(xlDown).Row)
.Range("H2").FormulaR1C1 = "=VLOOKUP(RC[-7],1ere feuille!C2:C7,6,FALSE)"
Sheets("5eme feuille").Range("H2").AutoFill Destination:=Sheets("5eme feuille").Range("H2:H" & Range("A1").End(xlDown).Row)
Range(Range("I1:M1"), Range("I1:M1").End(xlDown)).Value = Range(Range("D1:H1"), Range("D1:H1").End(xlDown)).Value
Columns("D:H").Delete Shift:=xlToLeft
End With
Sheets("5eme feuille").Select
Else: MsgBox "Votre feuille 5eme feuille est déjà créée ! Pour la re-créer, supprimer celle existante et relancez la macro.", vbInformation + vbOKOnly, "Erreur feuille déjà créée"
Exit Sub
End If
Application.ScreenUpdating = True
End Sub |
Partager