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 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650
| Sub Recup_donnees_pour_TDB()
'Déclaration des variables
'
Dim nbr As Integer
Dim Derlig As Integer
Dim i As Integer
Dim y As Integer
Dim x As String
Dim Program As String
Dim PO As String
Dim PO_Date As Variant
Dim Content As String
Dim Method As String
Dim Deliv_Target_Date As Variant
Dim First_Deliv_Date As Variant
Dim Last_Deliv_Date As Variant
Dim Compliant_Deliv_Date As Variant
Dim Active_loop As Variant
Dim Reject_Date_Loop1 As Variant
Dim Reject_Date_Loop2 As Variant
Dim Reject_Date_Loop3 As Variant
Dim Reject_Date_Loop4 As Variant
Dim Reject_Date_Loop5 As Variant
Dim Quality_OQD As String
Dim On_Time_Deliv As Variant
Dim Deliv_Note_FOURNISS As Variant
Dim Deliv_Note_CLIENT As Variant
Dim Good_Receipt As Variant
Dim Status As String
Dim Comments As String
Dim Hyperlink As String
Dim Buffer As Integer
Dim statusBarInitial As Long
'
'Déclaration des variables relatives au check date
'
Dim check_PO_Date As String
Dim check_Deliv_Target_Date As String
Dim check_First_Deliv_Date As String
Dim check_Last_Deliv_Date As String
Dim check_Compliant_Deliv_Date As String
Dim check_Reject_Date_Loop1 As String
Dim check_Reject_Date_Loop2 As String
Dim check_Reject_Date_Loop3 As String
Dim check_Reject_Date_Loop4 As String
Dim check_Reject_Date_Loop5 As String
Dim check_Deliv_Note_FOURNISS As String
Dim check_Deliv_Note_CLIENT As String
Dim check_Good_Receipt As String
'On protège l'onglet "FEUIL1" mais cependant on rends possible les modifications de cette feuille via la macro
'Worksheets("Feuil1").Protect , UserInterfaceOnly:=True
'Sablier
Application.Cursor = xlWait
'Exécution de la macro "Recuperation_Noms_sous_dossiers"
Call Recuperation_Noms_sous_dossiers
'Permet de ne pas avoir à cliquer sur OK à chaque fois que c'est demandé (msgbox). Ainsi la validation est automatique
Application.EnableEvents = False
nbr = 0
'
'On est dans le fichier "FOLLOW_UP_FOURNISS.xlsm", onglet "FEUIL1"
'
'Recherche du numéro de la dernière ligne non vide en partant de B6 (dernier ID) --> derlig
'Recherche du nombre de références ID en colonne B --> nbr
'
Derlig = Application.WorksheetFunction.CountA(Range("B:B")) + 3
nbr = Range("B6:B" & Derlig).SpecialCells(xlCellTypeVisible).Count
'Affichage dans une boite de dialogue du nombre de références ID
MsgBox ("You have " & nbr & " ID's references")
'Initialisation des compteurs (on part de la ligne 6)
i = 1
y = 6
'Boucle sur le nombre de références ID, nbr (remplissage du tableau)
statusBarInitial = Application.DisplayStatusBar
Application.DisplayStatusBar = True
While i <= nbr
Application.StatusBar = "Calcul en cours... " & i & " / " & nbr
DoEvents
'Activation du fichier "FOLLOW_UP_FOURNISS.xlsm", on se place dans l'onglet "Feuil1"
Windows("FOLLOW_UP_FOURNISS.xlsm").Activate
Sheets("Feuil1").Activate
'x correspond à la valeur de la cellule B6 (première valeur de la liste)
x = Range("B" & y).Value
'
'
'Ouverture du fichier "Entry_Form_ID.....xlsm" situé dans le dossier racine auquel on rajoute le sous-dossier ID....
'Activation de l'onglet "ADD_INFOS"
Workbooks.Open Filename:=Dossier_racine & "\" & x & "\" & "Entry_Form_" & x & ".xlsm"
Sheets("ADD_INFOS").Activate
'
'S'il y a un message d'erreur alors aller à l'étiquette fin.
On Error GoTo fin
'
'Affiche pendant 1 seconde le nom du fichier en cours de traitement, cette fenêtre disparait ensuite et la procédure se poursuit
CreateObject("Wscript.shell").Popup "Please wait" & Chr(10) & Chr(10) & "File " & "Entry_Form_" & x & ".xlsm", 1, "For information", vbInformation
'
'-----------------------------------------------------------------------------
'
' Mise en mémoire des données du fichier "Entry_Form_ID.....xlsm".
' Celles-ci seront rapatriées dans le fichier "FOLLOW_UP_FOURNISS.xlsm"
'
'-----------------------------------------------------------------------------
'
'
'------Program (C7)------
'
If Range("C7").Value = "" Then
Program = ""
Else
Program = Range("C7").Value
End If
'
'
'------PO (C8)------
'
If Range("C8").Value = "" Then
PO = ""
Else
PO = Range("C8").Value
End If
'
'
'------PO_Date (C9)------
'
check_PO_Date = IsDate(Range("C9").Value)
If check_PO_Date Then
'MsgBox ("check PO date est vrai")
PO_Date = Range("C9").Value
Else
'MsgBox ("check PO date est faux")
PO_Date = ""
End If
'
'
'------Content (C10)------
'
If Range("C10").Value = "" Then
Content = ""
Else
Content = Range("C10").Value
End If
'
'
'------Method (C11)------
'
If Range("C11").Value = "" Then
Method = ""
Else
Method = Range("C11").Value
End If
'
'
'------Deliv_Target_Date (H6)------
'
check_Deliv_Target_Date = IsDate(Range("H6").Value)
'MsgBox ("Deliv_Target_Date = ") & check_Deliv_Target_Date & Range("H6").Value
If check_Deliv_Target_Date Then
Deliv_Target_Date = Range("H6").Value
'MsgBox ("Deliv Target Date VRAI")
Else
'MsgBox ("Deliv Target Date FAUX")
Deliv_Target_Date = ""
'MsgBox ("Deliv_Target_Date = ") & Deliv_Target_Date
End If
'
'
'------First Deliv Date (H8)------
'
check_First_Deliv_Date = IsDate(Range("H8").Value)
'MsgBox ("First_Deliv_Date = ") & check_First_Deliv_Date & Range("H8").Value
If check_First_Deliv_Date Then
First_Deliv_Date = Range("H8").Value
'MsgBox ("VRAI")
Else
'MsgBox ("FAUX")
First_Deliv_Date = "NOT YET DELIVERED"
'MsgBox ("First_Deliv_Date = ") & First_Deliv_Date
End If
'
'
'------Last Deliv Date (H9)------
'
check_Last_Deliv_Date = IsDate(Range("H9").Value)
'MsgBox ("Last_Deliv_Date = ") & check_Last_Deliv_Date & Range("H9").Value
If check_Last_Deliv_Date Then
Last_Deliv_Date = Range("H9").Value
'MsgBox ("VRAI")
Else
'MsgBox ("FAUX")
Last_Deliv_Date = "NOT YET DELIVERED"
'MsgBox ("Last_Deliv_Date = ") & Last_Deliv_Date
End If
'
'
'------Compliant Deliv Date (H11)------
'
check_Compliant_Deliv_Date = IsDate(Range("H11").Value)
'MsgBox ("Compliant_Deliv_Date = ") & check_Compliant_Deliv_Date & Range("H11").Value
If check_Compliant_Deliv_Date Then
Compliant_Deliv_Date = Range("H11").Value
'MsgBox ("VRAI")
Else
'MsgBox ("FAUX")
Compliant_Deliv_Date = "NO COMPLIANT DATE"
'MsgBox ("Compliant_Deliv_Date = ") & Compliant_Deliv_Date
End If
'
'
'------Active loop (H14)------
'
If Range("H14").Value = "" Then
Active_loop = ""
Else
Active_loop = Range("H14").Value
End If
'
'
'------Attention on change d'onglet------
'
Sheets("NDT_Delivery").Activate
'
'
'------Reject Date Loop1 (C13)------
'
check_Reject_Date_Loop1 = IsDate(Range("C13").Value)
'MsgBox ("Reject_Date_Loop1 = ") & check_Reject_Date_Loop1 & Range("C13").Value
If check_Reject_Date_Loop1 Then
Reject_Date_Loop1 = Range("C13").Value
'MsgBox ("VRAI")
Else
'MsgBox ("FAUX")
Reject_Date_Loop1 = "NO"
'MsgBox ("Reject_Date_Loop1 = ") & Reject_Date_Loop1
End If
'
'
'------Reject Date Loop2 (C53)------
'
check_Reject_Date_Loop2 = IsDate(Range("C53").Value)
'MsgBox ("Reject_Date_Loop2 = ") & check_Reject_Date_Loop2 & Range("C53").Value
If check_Reject_Date_Loop2 Then
Reject_Date_Loop2 = Range("C53").Value
'MsgBox ("VRAI")
Else
'MsgBox ("FAUX")
Reject_Date_Loop2 = "NO"
'MsgBox ("Reject_Date_Loop2 = ") & Reject_Date_Loop2
End If
'
'
'------Reject Date Loop3 (C93)------
'
check_Reject_Date_Loop3 = IsDate(Range("C93").Value)
'MsgBox ("Reject_Date_Loop3 = ") & check_Reject_Date_Loop3 & Range("C93").Value
If check_Reject_Date_Loop3 Then
Reject_Date_Loop3 = Range("C93").Value
'MsgBox ("VRAI")
Else
'MsgBox ("FAUX")
Reject_Date_Loop3 = "NO"
'MsgBox ("Reject_Date_Loop3 = ") & Reject_Date_Loop3
End If
'
'
'------Reject Date Loop4 (C133)------
'
check_Reject_Date_Loop4 = IsDate(Range("C133").Value)
'MsgBox ("Reject_Date_Loop4 = ") & check_Reject_Date_Loop4 & Range("C133").Value
If check_Reject_Date_Loop4 Then
Reject_Date_Loop4 = Range("C133").Value
'MsgBox ("VRAI")
Else
'MsgBox ("FAUX")
Reject_Date_Loop4 = "NO"
'MsgBox ("Reject_Date_Loop4 = ") & Reject_Date_Loop4
End If
'
'
'------Reject Date Loop5 (C173)------
'
check_Reject_Date_Loop5 = IsDate(Range("C173").Value)
'MsgBox ("Reject_Date_Loop5 = ") & check_Reject_Date_Loop5 & Range("C173").Value
If check_Reject_Date_Loop5 Then
Reject_Date_Loop5 = Range("C173").Value
'MsgBox ("VRAI")
Else
'MsgBox ("FAUX")
Reject_Date_Loop5 = "NO"
'MsgBox ("Reject_Date_Loop5 = ") & Reject_Date_Loop5
End If
'
'
'------Attention on change à nouveau d'onglet------
'
Sheets("ADD_INFOS").Activate
'
'
'------Quality_OQD (L8)------
'
If Range("L8").Value = "" Then
Quality_OQD = ""
Else
Quality_OQD = Range("L8").Value
End If
'
'------On Time Delivery (L12)------
'
If Range("L12").Value = "" Then
On_Time_Deliv = ""
Else
On_Time_Deliv = Range("L12").Value
End If
'
'
'------Deliv note sent by FOURNISS (D21)------
'
check_Deliv_Note_FOURNISS = IsDate(Range("D21").Value)
'MsgBox ("Deliv_Note_FOURNISS = ") & check_Deliv_Note_FOURNISS & Range("D21").Value
If check_Deliv_Note_FOURNISS Then
Deliv_Note_FOURNISS = Range("D21").Value
'MsgBox ("VRAI")
Else
'MsgBox ("FAUX")
Deliv_Note_FOURNISS = "NO"
'MsgBox ("Deliv_Note_FOURNISS = ") & Deliv_Note_FOURNISS
End If
'
'
'------Deliv note sent by CLIENT (D22)------
'
check_Deliv_Note_CLIENT = IsDate(Range("D22").Value)
'MsgBox ("Deliv_Note_CLIENT = ") & check_Deliv_Note_CLIENT & Range("D22").Value
If check_Deliv_Note_CLIENT Then
Deliv_Note_CLIENT = Range("D22").Value
'MsgBox ("VRAI")
Else
'MsgBox ("FAUX")
Deliv_Note_CLIENT = "NO"
'MsgBox ("Deliv_Note_CLIENT = ") & Deliv_Note_CLIENT
End If
'
'
'------Good_Receipt (G21)------
'
check_Good_Receipt = IsDate(Range("G21").Value)
'MsgBox ("Good_Receipt = ") & check_Good_Receipt & Range("G21").Value
If check_Good_Receipt Then
Good_Receipt = Range("G21").Value
'MsgBox ("VRAI")
Else
'MsgBox ("FAUX")
Good_Receipt = "NO"
'MsgBox ("Good_Receipt = ") & Good_Receipt
End If
'
'
'------Status (G22)------
'
If Range("G22").Value = "" Then
Status = ""
Else
Status = Range("G22").Value
End If
'
'
'------Comments (G23)------
'
If Range("G23").Value = "" Then
Comments = ""
Else
Comments = Range("G23").Value
End If
'
'
'------I-Share Hyperlink (C31)------
'
If Range("C31").Value = "" Then
Hyperlink = ""
Else
Hyperlink = Range("C31").Value
End If
'
'
'------Buffer (R14)------
'
If Range("R14").Value = "" Then
Buffer = ""
Else
Buffer = Range("R14").Value
End If
'
'
'------------------------------------------------------------------------------
'
' Fin de mise en mémoire des données du fichier "Entry_Form_ID.....xlsm".
'
'------------------------------------------------------------------------------
'
'
'On active le fichier "FOLLOW_UP_FOURNISS.xlsm" et on se mets dans l'onglet "Feuil1"
Windows("FOLLOW_UP_FOURNISS.xlsm").Activate
Sheets("Feuil1").Activate
'
'
'On colle les valeurs précédemment mises en mémoire dans le fichier "FOLLOW_UP_FOURNISS.xlsm" (onglet "Feuil1")
'
'
'------Program------
'
Range("C" & y).Value = Program
'
'
'------PO------
'
Range("D" & y).Value = PO
'
'
'------PO_Date------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(PO_Date) Then
Range("E" & y).NumberFormat = ""
Range("E" & y).Value = CDate(PO_Date)
Else
Range("E" & y).Value = PO_Date
End If
'
'
'------Content------
'
Range("F" & y).Value = Content
'
'
'------Method------
'
Range("G" & y).Value = Method
'
'
'------Deliv_Target_Date------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(Deliv_Target_Date) Then
Range("H" & y).NumberFormat = ""
Range("H" & y).Value = CDate(Deliv_Target_Date)
Else
Range("H" & y).Value = Deliv_Target_Date
End If
'
'
'------First_Deliv_Date------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(First_Deliv_Date) Then
Range("I" & y).NumberFormat = ""
Range("I" & y).Value = CDate(First_Deliv_Date)
Else
Range("I" & y).Value = First_Deliv_Date
End If
'
'
'------Last_Deliv_Date------
'
If IsDate(Last_Deliv_Date) Then
Range("J" & y).NumberFormat = ""
Range("J" & y).Value = CDate(Last_Deliv_Date)
Else
Range("J" & y).Value = Last_Deliv_Date
End If
'
'
'------Compliant_Deliv_Date------
'
If IsDate(Compliant_Deliv_Date) Then
Range("K" & y).NumberFormat = ""
Range("K" & y).Value = CDate(Compliant_Deliv_Date)
Else
Range("K" & y).Value = Compliant_Deliv_Date
End If
'
'
'------Active_Loop------
'
Range("L" & y).Value = Active_loop
'
'
'------Reject_Date_Loop1------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(Reject_Date_Loop1) Then
Range("M" & y).NumberFormat = ""
Range("M" & y).Value = CDate(Reject_Date_Loop1)
Else
Range("M" & y).Value = Reject_Date_Loop1
End If
'
'
'------Reject_Date_Loop2------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(Reject_Date_Loop2) Then
Range("N" & y).NumberFormat = ""
Range("N" & y).Value = CDate(Reject_Date_Loop2)
Else
Range("N" & y).Value = Reject_Date_Loop2
End If
'
'
'------Reject_Date_Loop3------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(Reject_Date_Loop3) Then
Range("O" & y).NumberFormat = ""
Range("O" & y).Value = CDate(Reject_Date_Loop3)
Else
Range("O" & y).Value = Reject_Date_Loop3
End If
'
'
'------Reject_Date_Loop4------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(Reject_Date_Loop4) Then
Range("P" & y).NumberFormat = ""
Range("P" & y).Value = CDate(Reject_Date_Loop4)
Else
Range("P" & y).Value = Reject_Date_Loop4
End If
'
'
'------Reject_Date_Loop5------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(Reject_Date_Loop5) Then
Range("Q" & y).NumberFormat = ""
Range("Q" & y).Value = CDate(Reject_Date_Loop5)
Else
Range("Q" & y).Value = Reject_Date_Loop5
End If
'
'
'------Quality OQD------
'
Range("R" & y).Value = Quality_OQD
'
'
'------On Time Deliv------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(On_Time_Deliv) Then
Range("S" & y).NumberFormat = ""
Range("S" & y).Value = CDate(On_Time_Deliv)
Else
Range("S" & y).Value = On_Time_Deliv
End If
'
'
'------Deliv_Note_FOURNISS------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(Deliv_Note_FOURNISS) Then
Range("T" & y).NumberFormat = ""
Range("T" & y).Value = CDate(Deliv_Note_FOURNISS)
Else
Range("T" & y).Value = Deliv_Note_FOURNISS
End If
'
'
'------Deliv_Note_CLIENT------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(Deliv_Note_CLIENT) Then
Range("U" & y).NumberFormat = ""
Range("U" & y).Value = CDate(Deliv_Note_CLIENT)
Else
Range("U" & y).Value = Deliv_Note_CLIENT
End If
'
'
'------Good_Receipt------La formulation ci-dessous permet d'éviter l'inversion jour / mois
'
If IsDate(Good_Receipt) Then
Range("V" & y).NumberFormat = ""
Range("V" & y).Value = CDate(Good_Receipt)
Else
Range("V" & y).Value = Good_Receipt
End If
'
'
'------Status------
'
Range("W" & y).Value = Status
'
'
'------Comments------
'
Range("X" & y).Value = Comments
'
'
'------Récupération du lien hypertexte------
'
ActiveSheet.Hyperlinks.Add Anchor:=Range("Y" & y), Address:=Hyperlink, TextToDisplay:=Range("B" & y).Value
'
'
'------Buffer------
'
Range("Z" & y).Value = Buffer
'
'
'
y = y + 1
i = i + 1
'Fermer le fichier "Entry_Form_ID....xlsm" sans l'enregistrer (false)
Workbooks("Entry_Form_" & x & ".xlsm").Close False
Wend
Application.StatusBar = ""
Application.DisplayStatusBar = statusBarInitial
'On active le fichier "FOLLOW_UP_FOURNISS.xlsm" et on se mets dans l'onglet "Feuil1"
Windows("FOLLOW_UP_FOURNISS.xlsm").Activate
Sheets("Feuil1").Activate
Range("A1").Select
MsgBox ("Update finished")
Application.EnableEvents = True
'Exécution de la macro "SaveFile"
Call SaveFile
Application.Cursor = xlDefault
'Permet de sortir de la procédure et évite la gestion d'erreur (errorHandler), si la macro
's'est déroulée sans encombre.
Exit Sub
fin:
'Activation du fichier "FOLLOW_UP_FOURNISS.xlsm", on se place dans l'onglet "Feuil1"
Windows("FOLLOW_UP_FOURNISS.xlsm").Activate
Sheets("Feuil1").Activate
MsgBox ("Warning : Procedure interrupted due to error")
End Sub |
Partager