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
| Sub Calcul()
Application.ScreenUpdating = False
Dim i As Integer
Dim PN As String
Dim Col_PN As Integer
Dim NB_OF As Integer
Dim No_OF As String
Dim p As Integer
Dim Retard_J As Integer
Dim Nb_Retard As Integer
'On Error GoTo Err1
'Efface les data précédentes
Workbooks("Planification SS_MOD8.XLSM").Sheets("Data SAP").Activate
Range("A2:BB300").Select
Selection.Clear
'Reconaissance des colonnes
Dim No_Col_Order As Integer
Dim No_Col_Material As Integer
Dim No_Col_FinishDate As Integer
Workbooks("WIP.XLS").Activate
Sheets("WIP").Activate
For i = 1 To 100
If Cells(7, i) = "Order" Then
No_Col_Order = i
End If
If Cells(7, i) = "Material" Then
No_Col_Material = i
End If
If Cells(7, i) = "Basic fin." Then
No_Col_FinishDate = i
End If
If No_Col_Order <> 0 And No_Col_Material <> 0 And No_Col_FinishDate <> 0 Then
i = 101
End If
Next i
'Mise en format des dates
Windows("WIP.XLS").Activate
Range("D9").Select
ActiveCell.FormulaR1C1 = _
"=IFERROR(VLOOKUP(RC[" & No_Col_FinishDate - 4 & "],'[Planification SS_MOD8.xlsm]Index'!C10:C11,2,0),"""")"
Range("D9").Select
Selection.AutoFill Destination:=Range("D9:D500")
Range("D9:D500").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.NumberFormat = "m/d/yyyy"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
For i = 2 To 28
Workbooks("Planification SS_MOD8.xlsm").Sheets("Index").Activate
PN = Cells(i, 2)
Col_PN = Cells(i, 4)
NB_OF = Cells(i, 5)
For p = 9 To 500
Workbooks("WIP.XLS").Sheets("WIP").Activate
If Cells(p, No_Col_Material) = PN And Cells(p, No_Col_Material) <> "" Then
No_OF = Cells(p, No_Col_Order)
Retard_J = Cells(p, 4) - Date ' <---------------- Ligne qui pose problème
Workbooks("Planification SS_MOD8.xlsm").Sheets("Data SAP").Activate
If Retard_J < 0 Then
Nb_Retard = Nb_Retard + 1
End If
Cells(2 + NB_OF, Col_PN + 1) = Retard_J
Cells(2 + NB_OF, Col_PN) = No_OF
NB_OF = Sheets("Index").Cells(i, 5)
End If
Next p
Workbooks("Planification SS_MOD8.xlsm").Sheets("Index").Activate
Cells(i, 7) = Nb_Retard
Nb_Retard = 0
Next i
'Efface précédent
Workbooks("Planification SS_MOD8.xlsm").Sheets("Planification").Activate
Range("C14:W14").Select
Range("C21:W21").Select
Workbooks("WIP.XLS").Close False
Workbooks("Planification SS_MOD8.xlsm").Sheets("Planification").Activate
'Exit Sub
'Err1:
' MsgBox Err.Number & vbLf & Err.Description
End Sub |
Partager