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 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555
| 'Option Explicit
Sub Macro1()
'Sheets("ECO-CONDUITE - F").Select
'Cells.Copy
'Sheets("ECO-CONDUITE").Select
'Cells.Select
'Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
'Selection.Replace What:=",", Replacement:=".", LookAt:=xlPart, _
'SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
'ReplaceFormat:=False
Set activeMacro = ActiveWorkbook
'ouvrir fichier rapport de synthese
Dim syntheseFile, rulesFile As Workbook
Set syntheseFile = openFile("Veuillez fournir le rapport de synthese")
'ouvrir fichier des règles
Set rulesFile = openFile("Veuillez fournir le fichier des regles")
'copier contenu onglet eco-conduite dans le fichier de syntheses
'Workbooks("MACRO Eco-conduite.xls").Sheets("ECO-CONDUITE").Copy After:=syntheseFile.Sheets(syntheseFile.Sheets.Count)
'copier contenu onglet regles dans le fichier de syntheses
rulesFile.Sheets("REGLES").Copy After:=syntheseFile.Sheets(syntheseFile.Sheets.Count)
'renommer en fichier stat
onglet_stat activeMacro, syntheseFile
syntheseFile.SaveAs Filename:=syntheseFile.Path & "\STATS - " & syntheseFile.Name
activity_report syntheseFile
'Macro_fiches activeMacro, syntheseFile
End Sub
Function openFile(FileNameMessage As String)
Application.Caption = "Ouverture de la base"
response = MsgBox(FileNameMessage, vbOKCancel + vbCritical + vbExclamation, "Ouvrir un fichier")
If response = vbOK Then
FileToOpen = Application.GetOpenFilename("Le fichier correspondant (*.xls), *.xls", , "Selection du fichier requis")
If FileToOpen <> False Then
Workbooks.Open Filename:=FileToOpen
Set file = ActiveWorkbook
Else
End
End If
End If
Application.DisplayAlerts = False
Set openFile = file
End Function
Sub onglet_stat(ByVal FicMacro As Workbook, ByVal DonneesSource As Workbook)
'Dim DonneesSource As Object
Dim Chemin As String
'Dim FicMacro As Object
Dim Onglet As Integer
Dim Nomfich As String
Application.ScreenUpdating = False
'Set FicMacro = ActiveWorkbook
FicMacro.Sheets("formules").Visible = True
FicMacro.Sheets("STAT").Visible = True
'1 - Ouverture du fichier et ajout de l'onglet STAT
tot = DonneesSource.Sheets.Count
Chemin = DonneesSource.Path
Nomfich = DonneesSource.Name
For Onglet = 1 To tot
If DonneesSource.Sheets(Onglet).Range("A2") = "Nom du client" Then
Sheets(Onglet).Name = "REGLES"
' Sheets(Onglet).Move After:=Sheets(DonneesSource.Sheets.Count)
' ElseIf DonneesSource.Sheets(Onglet).Name = "ECO-CONDUITE" Then
' Sheets(Onglet).Move After:=Sheets(DonneesSource.Sheets.Count)
End If
Next
Sheets("REGLES").Move After:=Sheets(DonneesSource.Sheets.Count)
'Sheets("ECO-CONDUITE").Move After:=Sheets(DonneesSource.Sheets.Count)
tot = tot - 1 'yavé 2
For Onglet = 1 To tot
If Onglet > tot Then Exit For
If DonneesSource.Sheets(Onglet).Range("B1") = "" Then
DonneesSource.Sheets(Onglet).Delete
Onglet = Onglet - 1
tot = tot - 1
End If
Next
Sheets(1).Select
Sheets.Add
ActiveSheet.Name = "STAT"
Sheets("STAT").Move After:=Sheets(DonneesSource.Sheets.Count)
FicMacro.Sheets("STAT").Activate
Range("A:A").Copy
DonneesSource.Sheets("STAT").Activate
Cells(1, 1).Select
ActiveSheet.Paste
'2 - Ajout des colonnes de formules sur chaque onglet
For Onglet = 1 To DonneesSource.Sheets.Count - 2 'yavé 3
FicMacro.Sheets("formules").Activate
Range("N1:AM2").Copy
DonneesSource.Sheets(Onglet).Activate
DonneesSource.Sheets(Onglet).Cells(1, 14).Select
ActiveSheet.Paste
DonneesSource.Sheets(Onglet).Range("N2:AM2").Copy
DonneesSource.Sheets(Onglet).Cells(65000, 13).End(xlUp).Offset(0, 1).Select
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
' Columns("N:AG").AutoFit
'3 - copie des synthèses sur l'onglet STAT
Sheets(Onglet).Range("A:A").Select
Selection.Find(What:="Amplitude", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Activate
Lint_Synth = ActiveCell.Row
Sheets(Onglet).Range("B" & Lint_Synth & ":B" & Lint_Synth + 10).Copy
Sheets("STAT").Select
Cells(4, Onglet + 1).Select
ActiveSheet.Paste
Sheets("STAT").Cells(3, Onglet + 1).Value = Sheets(Onglet).Name
Sheets("STAT").Cells(2, Onglet + 1).Value = Left(Nomfich, InStr(1, Nomfich, "-") - 1)
Sheets("STAT").Cells(1, Onglet + 1).Value = Left(Right(Nomfich, Len(Nomfich) - InStr(1, Nomfich, "periode") - 7), Len(Right(Nomfich, Len(Nomfich) - InStr(1, Nomfich, "periode") - 7)) - 4)
'4 - Ajout des formules sur l'onglet STAT
FicMacro.Sheets("STAT").Activate
Range("B14:B100").Copy
DonneesSource.Sheets("STAT").Activate
Cells(14, Onglet + 1).Select
ActiveSheet.Paste
Columns(Onglet + 1).Select
Selection.Replace What:="[MACRO Eco-conduite.xls]formules", Replacement:=Sheets(Onglet).Name, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
', SearchFormat:=False, _
ReplaceFormat:=False
Columns(Onglet + 1).AutoFit
' Columns(Onglet + 1).Select
' Selection.Copy
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
' :=False, Transpose:=False
'4b - Ajout des lignes 41 et +
DonneesSource.Sheets("REGLES").Activate
Rows(3 & ":" & 3).Select
Selection.Find(What:=DonneesSource.Sheets("STAT").Cells(3, Onglet + 1).Value, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext).Activate
colregle = ActiveCell.Column
Range(Cells(4, colregle), Cells(39, colregle)).Copy
DonneesSource.Sheets("STAT").Select
Cells(41, Onglet + 1).Select
ActiveSheet.Paste
'4c - calcul de l'arret le plus cité
recurence = 0
motmax = 0
'Boucle de recherche de l'arret
For b = 2 To DonneesSource.Sheets(Onglet).Cells(65000, 5).End(xlUp).Row
reference = DonneesSource.Sheets(Onglet).Cells(b, 5).Value
'boucle
For j = 2 To DonneesSource.Sheets(Onglet).Cells(65000, 5).End(xlUp).Row
If DonneesSource.Sheets(Onglet).Cells(j, 5).Value = reference Then
recurence = recurence + 1
End If
Next
If recurence > motmax Then
motmax = recurence
motmaxvaleur = reference
End If
recurence = 0
Next
'affichage du resultat
DonneesSource.Sheets("STAT").Cells(19, Onglet + 1).Value = motmaxvaleur
'4d - calcul de l'arret POI le plus cité
recurence = 0
motmax = 0
'Boucle de recherche de l'arret
If DonneesSource.Sheets("STAT").Cells(84, Onglet + 1).Value > 0 Then
l = 2
If DonneesSource.Sheets(Onglet).Cells(l, 31).Value = "" Then
Do While DonneesSource.Sheets(Onglet).Cells(l, 31).Value = ""
l = l + 1
Loop
End If
For b = l To DonneesSource.Sheets(Onglet).Cells(65000, 5).End(xlUp).Row
reference = DonneesSource.Sheets(Onglet).Cells(b, 33).Value
'boucle
For j = l To DonneesSource.Sheets(Onglet).Cells(65000, 5).End(xlUp).Row
If DonneesSource.Sheets(Onglet).Cells(j, 33).Value <> "" And DonneesSource.Sheets(Onglet).Cells(j, 33).Value = reference Then
recurence = recurence + 1
End If
Next
If recurence > motmax Then
motmax = recurence
motmaxvaleur = reference
End If
recurence = 0
Next
'affichage du resultat
DonneesSource.Sheets("STAT").Cells(89, Onglet + 1).Value = motmaxvaleur
End If
'5 - Suppression des colonnes de formule inutiles
DonneesSource.Sheets(Onglet).Select
Range("AE:AM").Select
Selection.Replace What:="[MACRO Eco-conduite.xls]", Replacement _
:="", LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase:=False
' Selection.Copy
' Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Cells(1, 1).Select
ActiveWindow.Zoom = 85
Range("A1").Select
Selection.AutoFilter
Range("A2").Activate
ActiveWindow.FreezePanes = True
'5b - recup du temps de depassement
''DonneesSource.Sheets("ECO-CONDUITE").Select
''Range("B:B").Select
''Selection.Find(What:=DonneesSource.Sheets("STAT").Cells(3, Onglet + 1).Value, After:=ActiveCell, LookIn:=xlFormulas, _
''LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext).Activate
''DonneesSource.Sheets("STAT").Cells(77, Onglet + 1).Value = ActiveCell.Offset(0, 17).Value
''DonneesSource.Sheets("STAT").Cells(20, Onglet + 1).Value = ActiveCell.Offset(0, 13).Value
''DonneesSource.Sheets("STAT").Cells(14, Onglet + 1).Value = ActiveCell.Offset(0, 15).Value
Next
'6 - Mise en forme & Enregistrement
DonneesSource.Sheets("STAT").Select
Cells.Select
Cells.Font.Name = "Tahoma"
Cells.Font.Size = 8
Rows(1 & ":" & 3).Font.ColorIndex = 3
Rows(1 & ":" & 3).IndentLevel = 1
'DonneesSource.SaveAs Filename:=Chemin & "\STATS - " & Nomfich
FicMacro.Activate
Sheets(Array("formules", "STAT")).Select
Sheets("formules").Activate
ActiveWindow.SelectedSheets.Visible = False
DonneesSource.Activate
Cells(1, 1).Select
End Sub
Sub activity_report(ByVal DonneesSource As Workbook)
'
' Macro1 Macro
' Macro enregistrée le 22/02/2011 par ABV
'
Dim Chemin_Maq As String
Dim Chemin As String
'Dim DonneesSource As Object
Dim MAQ As Object
Dim LigneCopie As Integer
Dim ColDonnees As Integer
Chemin_Maq = ActiveWorkbook.Path
Chemin = DonneesSource.Path
'2 Ouvrir la maquette et l'enregistrer sous un nouveau nom = DANS LE MEME REPERTOIRE QUE LE FICHIER TRAITE
Workbooks.Open Filename:=Chemin_Maq & "\Rapports pour automatisation.xls"
ActiveWorkbook.SaveAs Filename:=Chemin & "\" & DonneesSource.Sheets("STAT").Cells(2, 2).Value & " Rapport d'activité du " & DonneesSource.Sheets("STAT").Cells(1, 2).Value & ".xls"
Set MAQ = ActiveWorkbook
'4 Saisir les données
'Page de garde
MAQ.Sheets("Page de garde").Cells(20, 1).Value = DonneesSource.Sheets("STAT").Cells(2, 2).Value
MAQ.Sheets("Page de garde").Cells(25, 5).Value = DonneesSource.Sheets("STAT").Cells(1, 2).Value
LigneCopie = 14
For ColDonnees = 2 To DonneesSource.Sheets("STAT").Cells(2, 200).End(xlToLeft).Column
'Page 1.Eco conduite
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 2).Value = DonneesSource.Sheets("STAT").Cells(3, ColDonnees).Value
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 4).Value = DonneesSource.Sheets("STAT").Cells(42, ColDonnees).Value
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 5).Value = DonneesSource.Sheets("STAT").Cells(13, ColDonnees).Value
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 8).Value = DonneesSource.Sheets("STAT").Cells(14, ColDonnees).Value
'MsgBox (DonneesSource.Sheets("STAT").Cells(20, ColDonnees).Interior.ColorIndex)
'MsgBox (RGB(153, 204, 0))
'MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.ColorIndex = DonneesSource.Sheets("STAT").Cells(20, ColDonnees).Interior.ColorIndex
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 10).Value = DonneesSource.Sheets("STAT").Cells(78, ColDonnees).Value
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Value = DonneesSource.Sheets("STAT").Cells(20, ColDonnees).Value + 0
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 8).Value = DonneesSource.Sheets("STAT").Cells(14, ColDonnees).Value
If DonneesSource.Sheets("STAT").Cells(20, ColDonnees).Value <= 15 Then
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.Color = RGB(153, 204, 0)
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Font.Color = RGB(0, 0, 0)
'MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Font.ColorIndex = DonneesSource.Sheets("STAT").Cells(20, ColDonnees).Font.ColorIndex
ElseIf DonneesSource.Sheets("STAT").Cells(20, ColDonnees).Value > 30 Then
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.Color = RGB(255, 0, 0)
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Font.Color = RGB(255, 255, 255)
Else
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.Color = RGB(255, 204, 0)
MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Font.Color = RGB(0, 0, 0)
End If
'' DonneesSource.Sheets("ECO-CONDUITE").Activate
'' Range("B:B").Select
'' Selection.Find(What:=DonneesSource.Sheets("STAT").Cells(3, ColDonnees).Value, After:=ActiveCell, LookIn:=xlFormulas, _
'' LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext).Activate
'' ligneco = ActiveCell.Row
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 6).Value = DonneesSource.Sheets("ECO-CONDUITE").Cells(ligneco, 14).Value & " fois"
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 7).Value = DonneesSource.Sheets("ECO-CONDUITE").Cells(ligneco, 13).Value & " fois"
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Value = DonneesSource.Sheets("ECO-CONDUITE").Cells(ligneco, 22).Value + 0
'' If MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Value <= 15 Then
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Interior.Color = RGB(153, 204, 0)
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Value > 30 Then
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Interior.Color = RGB(255, 0, 0)
'' Else
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Interior.Color = RGB(255, 204, 0)
''End If
'MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Interior.ColorIndex = DonneesSource.Sheets("ECO-CONDUITE").Cells(ligneco, 22).Interior.ColorIndex
'MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Font.ColorIndex = DonneesSource.Sheets("ECO-CONDUITE").Cells(ligneco, 22).Interior.ColorIndex
'' If MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Value = "" Then
'' MsgBox ("Il n'y a pas de score d'ECO CONDUITE pour le mois N-1 du véhicule " & MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 2).Value)
'' Exit Sub
'' End If
'' If MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.Color = RGB(153, 204, 0) Then
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 14).Value = 1
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.Color = RGB(255, 204, 0) Then
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 14).Value = 2
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.Color = RGB(255, 0, 0) Then
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 14).Value = 3
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.Color = RGB(0, 0, 0) Then
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 14).Value = 4
'' End If
'' If MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Interior.Color = RGB(153, 204, 0) Then
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 15).Value = 1
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Interior.Color = RGB(255, 204, 0) Then
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 15).Value = 2
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Interior.Color = RGB(255, 0, 0) Then
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 15).Value = 3
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 13).Interior.Color = RGB(0, 0, 0) Then
'' MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 15).Value = 4
'' End If
'' MAQ.Sheets("1C Eco conduite ").Activate
'' If IsError(MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 16).Value) Then
'MsgBox (MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 16).Text)
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 16).Value = 1 Then
'' MAQ.Sheets("1C Eco conduite ").Cells(7, 2).Select
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 16).Value = 2 Then
'' MAQ.Sheets("1C Eco conduite ").Cells(7, 6).Select
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 16).Value = 3 Then
'' MAQ.Sheets("1C Eco conduite ").Cells(13, 2).Select
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 16).Value = 4 Then
'' MAQ.Sheets("1C Eco conduite ").Cells(13, 6).Select
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 16).Value = 5 Then
'' MAQ.Sheets("1C Eco conduite ").Cells(19, 2).Select
'' ElseIf MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 16).Value = 6 Then
'' MAQ.Sheets("1C Eco conduite ").Cells(19, 6).Select
'' End If
Do While ActiveCell <> ""
ActiveCell.Offset(1, 0).Activate
Loop
ActiveCell = MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 2).Value & " " & MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 3).Value
'Page 2 Consommations
MAQ.Sheets("2 consommations").Cells(LigneCopie, 3).Value = DonneesSource.Sheets("STAT").Cells(43, ColDonnees).Value
MAQ.Sheets("2 consommations").Cells(LigneCopie, 4).Value = DonneesSource.Sheets("STAT").Cells(6, ColDonnees).Value
MAQ.Sheets("2 consommations").Cells(LigneCopie, 6).Value = DonneesSource.Sheets("STAT").Cells(44, ColDonnees).Value
If MAQ.Sheets("2 consommations").Cells(LigneCopie, 7).Value < Replace(DonneesSource.Sheets("STAT").Cells(46, ColDonnees).Value, "<", "") + 0 Then
MAQ.Sheets("2 consommations").Cells(LigneCopie, 10).Interior.ColorIndex = 43
ElseIf MAQ.Sheets("2 consommations").Cells(LigneCopie, 7).Value > Replace(DonneesSource.Sheets("STAT").Cells(48, ColDonnees).Value, ">", "") + 0 Then
MAQ.Sheets("2 consommations").Cells(LigneCopie, 10).Interior.ColorIndex = 3
Else
MAQ.Sheets("2 consommations").Cells(LigneCopie, 10).Interior.ColorIndex = 44
End If
'Page 3 Activités
MAQ.Sheets("3 Activités").Cells(LigneCopie, 2).Value = DonneesSource.Sheets("STAT").Cells(21, ColDonnees).Value
MAQ.Sheets("3 Activités").Cells(LigneCopie, 3).Value = DonneesSource.Sheets("STAT").Cells(25, ColDonnees).Value
MAQ.Sheets("3 Activités").Cells(LigneCopie, 4).Value = DonneesSource.Sheets("STAT").Cells(26, ColDonnees).Value
MAQ.Sheets("3 Activités").Cells(LigneCopie, 5).Value = DonneesSource.Sheets("STAT").Cells(30, ColDonnees).Value
MAQ.Sheets("3 Activités").Cells(LigneCopie, 7).Value = DonneesSource.Sheets("STAT").Cells(6, ColDonnees).Value
'MsgBox (Left(Replace(DonneesSource.Sheets("STAT").Cells(65, ColDonnees).Value, "<", ""), 1))
'MsgBox (Right(DonneesSource.Sheets("STAT").Cells(65, ColDonnees).Value, 2))
'MsgBox (7 / 24)
If MAQ.Sheets("3 Activités").Cells(LigneCopie, 6).Value < Left(Replace(DonneesSource.Sheets("STAT").Cells(65, ColDonnees).Value, "<", ""), 1) / 24 Or MAQ.Sheets("3 Activités").Cells(LigneCopie, 6).Value > Right(DonneesSource.Sheets("STAT").Cells(65, ColDonnees).Value, 2) / 24 Then
MAQ.Sheets("3 Activités").Cells(LigneCopie, 8).Interior.ColorIndex = 3 'rouge
ElseIf MAQ.Sheets("3 Activités").Cells(LigneCopie, 6).Value >= Left(Replace(DonneesSource.Sheets("STAT").Cells(63, ColDonnees).Value, "<", ""), 2) / 24 And MAQ.Sheets("3 Activités").Cells(LigneCopie, 6).Value <= Right(Replace(DonneesSource.Sheets("STAT").Cells(63, ColDonnees).Value, ">", ""), 2) / 24 Then
MAQ.Sheets("3 Activités").Cells(LigneCopie, 8).Interior.ColorIndex = 43 'vert
Else
MAQ.Sheets("3 Activités").Cells(LigneCopie, 8).Interior.ColorIndex = 44 'orange
End If
'Page 4 Arrêts
' If Left(DonneesSource.Sheets("STAT").Cells(70, ColDonnees).Value, 6) <> "ne pas" Then
' MAQ.Sheets("4 Arrêts").Cells(LigneCopie, 2).Value = DonneesSource.Sheets("STAT").Cells(39, ColDonnees).Value
' MAQ.Sheets("4 Arrêts").Cells(LigneCopie, 3).Value = DonneesSource.Sheets("STAT").Cells(32, ColDonnees).Value
' MAQ.Sheets("4 Arrêts").Cells(LigneCopie, 4).Value = DonneesSource.Sheets("STAT").Cells(33, ColDonnees).Value
' MAQ.Sheets("4 Arrêts").Cells(LigneCopie, 5).Value = DonneesSource.Sheets("STAT").Cells(34, ColDonnees).Value
' MAQ.Sheets("4 Arrêts").Cells(LigneCopie, 6).Value = DonneesSource.Sheets("STAT").Cells(19, ColDonnees).Value
' MAQ.Sheets("4 Arrêts").Cells(LigneCopie, 7).Value = DonneesSource.Sheets("STAT").Cells(15, ColDonnees).Value / 100
' If MAQ.Sheets("4 Arrêts").Cells(LigneCopie, 3).Value < (Replace(DonneesSource.Sheets("STAT").Cells(72, ColDonnees).Value, "<", "") + 0) / (24 * 60) Then
' MAQ.Sheets("4 Arrêts").Cells(LigneCopie, 8).Interior.ColorIndex = 43
' ElseIf MAQ.Sheets("4 Arrêts").Cells(LigneCopie, 3).Value > (Replace(DonneesSource.Sheets("STAT").Cells(74, ColDonnees).Value, ">", "") + 0) / (24 * 60) Then
' MAQ.Sheets("4 Arrêts").Cells(LigneCopie, 8).Interior.ColorIndex = 3
' Else
' MAQ.Sheets("4 Arrêts").Cells(LigneCopie, 8).Interior.ColorIndex = 44
' End If
' End If
'Page 4 Arrêts sur les POIS
MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 2).Value = DonneesSource.Sheets("STAT").Cells(85, ColDonnees).Value
If DonneesSource.Sheets("STAT").Cells(86, ColDonnees).Value <> "" Then MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 3).Value = DonneesSource.Sheets("STAT").Cells(86, ColDonnees).Value
'If DonneesSource.Sheets("STAT").Cells(87, ColDonnees).Value <> "" Then MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 4).Value = DonneesSource.Sheets("STAT").Cells(87, ColDonnees).Value
If DonneesSource.Sheets("STAT").Cells(88, ColDonnees).Value <> "" Then
MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 5).Value = DonneesSource.Sheets("STAT").Cells(88, ColDonnees).Value
DonneesSource.Sheets(DonneesSource.Sheets("STAT").Cells(3, ColDonnees).Value).Activate
Range("AF:AE").Select
ActiveWorkbook.Names.Add Name:="base" & ColDonnees, RefersToR1C1:= _
"='" & DonneesSource.Sheets("STAT").Cells(3, ColDonnees).Value & "'!C32:C33"
DonneesSource.Sheets("STAT").Select
Cells(100, ColDonnees).Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R[-12]C,base" & ColDonnees & ",2,FALSE)"
MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 7).Value = DonneesSource.Sheets("STAT").Cells(100, ColDonnees).Value
End If
If DonneesSource.Sheets("STAT").Cells(89, ColDonnees).Value <> "" Then MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 6).Value = DonneesSource.Sheets("STAT").Cells(89, ColDonnees).Value
If MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 3).Value <> "" Then
If MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 3).Value < (Replace(DonneesSource.Sheets("STAT").Cells(72, ColDonnees).Value, "<", "") + 0) / (24 * 60) Then
MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 8).Interior.ColorIndex = 43
ElseIf MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 3).Value > (Replace(DonneesSource.Sheets("STAT").Cells(74, ColDonnees).Value, ">", "") + 0) / (24 * 60) Then
MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 8).Interior.ColorIndex = 3
Else
MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 8).Interior.ColorIndex = 44
End If
End If
' End If
'Page 5 anomalies WE
If DonneesSource.Sheets("STAT").Cells(36, ColDonnees).Value = "Pas d'activité le WE" Then
MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 4).Value = 0 - DonneesSource.Sheets("STAT").Cells(37, ColDonnees).Value
Else
MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 4).Value = DonneesSource.Sheets("STAT").Cells(36, ColDonnees).Value - DonneesSource.Sheets("STAT").Cells(37, ColDonnees).Value
End If
MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 5).Value = DonneesSource.Sheets("STAT").Cells(37, ColDonnees).Value
If DonneesSource.Sheets("STAT").Cells(61, ColDonnees).Value <> "interdit" Then
MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 6).Value = "autorisé"
ElseIf DonneesSource.Sheets("STAT").Cells(41, ColDonnees).Value = "VS" Then
If MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 4).Value > 0 Or MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 5).Value > 0 Then
MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 6).Interior.ColorIndex = 1
Else
MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 6).Interior.ColorIndex = 43
End If
ElseIf DonneesSource.Sheets("STAT").Cells(41, ColDonnees).Value = "VL" Then
' If MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 5).Value = 0 And MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 4).Value = 0 Then
' MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 6).Interior.ColorIndex = 43
If (MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 5).Value > 0 And DonneesSource.Sheets("STAT").Cells(61, ColDonnees).Value = "interdit") Or (MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 4).Value > 0 And DonneesSource.Sheets("STAT").Cells(60, ColDonnees).Value = "interdit") Then
MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 6).Interior.ColorIndex = 1
Else
MAQ.Sheets("5 anomalies WE").Cells(LigneCopie - 1, 6).Interior.ColorIndex = 43
End If
End If
'Page CONCLUSION conso
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 3).Font.ColorIndex = MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.ColorIndex
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 4).Font.ColorIndex = MAQ.Sheets("2 Consommations").Cells(LigneCopie, 10).Interior.ColorIndex
If (MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 3).Font.ColorIndex = 3 And MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 4).Font.ColorIndex = 43) Or (MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 3).Font.ColorIndex = 43 And MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 4).Font.ColorIndex = 3) Then
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Interior.ColorIndex = 44
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Font.ColorIndex = 44
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Value = "2"
ElseIf MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 3).Font.ColorIndex = 3 Or MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 4).Font.ColorIndex = 3 Then
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Interior.ColorIndex = 3
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Font.ColorIndex = 3
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Value = "3"
ElseIf MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 3).Font.ColorIndex = 44 Or MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 4).Font.ColorIndex = 44 Then
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Interior.ColorIndex = 44
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Font.ColorIndex = 44
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Value = "2"
Else
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Interior.ColorIndex = 43
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Font.ColorIndex = 43
MAQ.Sheets("CONCLUSION conso").Cells(LigneCopie, 5).Value = "1"
End If
'Page CONCLUSION activité
If MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.ColorIndex = 3 Or MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.ColorIndex = 43 Or MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.ColorIndex = 44 Then MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = MAQ.Sheets("1 Eco conduite").Cells(LigneCopie, 11).Interior.ColorIndex Else MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = 2
If MAQ.Sheets("3 Activités").Cells(LigneCopie, 8).Interior.ColorIndex = 3 Or MAQ.Sheets("3 Activités").Cells(LigneCopie, 8).Interior.ColorIndex = 43 Or MAQ.Sheets("3 Activités").Cells(LigneCopie, 8).Interior.ColorIndex = 44 Then MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = MAQ.Sheets("3 Activités").Cells(LigneCopie, 8).Interior.ColorIndex Else MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = 2
If MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 8).Interior.ColorIndex = 3 Or MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 8).Interior.ColorIndex = 43 Or MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 8).Interior.ColorIndex = 44 Then MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = MAQ.Sheets("4 Arrêts sur les POIS").Cells(LigneCopie, 8).Interior.ColorIndex Else MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = 2
If (MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = 3 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = 3 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = 3) Or _
(MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = 3 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = 3 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = 2) Or _
(MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = 3 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = 3 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = 43) Or _
(MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = 3 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = 43 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = 3) Or _
(MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = 43 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = 3 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = 3) Then
MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 6).Interior.ColorIndex = 3
MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 6).Font.ColorIndex = 3
MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 6).Value = "3"
ElseIf (MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = 43 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = 43 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = 43) Or _
(MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = 43 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = 43 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = 2) Or _
(MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = 43 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = 43 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = 44) Or _
(MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = 43 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = 44 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = 43) Or _
(MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 3).Font.ColorIndex = 44 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 4).Font.ColorIndex = 43 And MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 5).Font.ColorIndex = 43) Then
MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 6).Interior.ColorIndex = 43
MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 6).Font.ColorIndex = 43
MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 6).Value = "1"
Else
MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 6).Interior.ColorIndex = 44
MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 6).Font.ColorIndex = 44
MAQ.Sheets("CONCLUSION activité").Cells(LigneCopie + 2, 6).Value = "2"
End If
'Fiches véhicule
LigneCopie = LigneCopie + 1
Next
'MAQ.Sheets("1C Eco conduite ").Range("R:S").ClearContents
For s = 2 To MAQ.Sheets.Count
MAQ.Sheets(s).PageSetup.CenterHeader = "Période du " & DonneesSource.Sheets("STAT").Cells(1, 2).Value
Next
DonneesSource.Close [False]
MAQ.Save
End Sub |