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
| Sub test_heure()
Dim i As Long 'variable du tableau
Dim DL_SUIVI As Long 'derniere ligne suivi lot
Dim MaSom As Date 'compteur de lot trouvés(date2- date1)
Dim MonNb As Long 'nb total de test fait
Dim K As Range 'range de l'année et numéro de semaine en cours pour aller jusqu'a la dernière semaine actuelle feuille tdb
Dim L As Long 'ligne du find du range année /sem
Dim j As Long 'variable servant a passer chaque année et semaine de la feuille lsite du TdB CQ
Dim montableau() As Variant
Application.ScreenUpdating = False
'=====================================================================================
' Comptage temps entre fin réelle et fin prévu
'=====================================================================================
'T&F
DL_SUIVI = Workbooks("SUIVI_LOTS1.xls").Worksheets("Liste T&F").Cells(Rows.Count, 3).End(xlUp).Row + 1
Set K = ThisWorkbook.Worksheets("Liste").Range("A3:C54").Find(ThisWorkbook.Worksheets("TdB").Range("O2").Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not K Is Nothing Then
L = K.Row
End If
montableau() = Workbooks("SUIVI_LOTS1.xls").Worksheets("Liste T&F").Range("A3:K" & DL_SUIVI).Value
j = L
MaSom = 0 'remise compteur 0
MonNb = 0 'remise compteur 0
For i = LBound(montableau, 1) To UBound(montableau, 1) ' 1 car car on parcours les lignes (2 pour col)
If montableau(i, 5) <> "N/A" Then 'si pas de ste pour t&f
If Year(montableau(i, 5)) & DatePart("ww", montableau(i, 5)) = ThisWorkbook.Worksheets("Liste").Cells(j, 1).Value And montableau(i, 11) > montableau(i, 10) And montableau(i, 11) <> VIDE Then
MaSom = montableau(i, 11) - montableau(i, 10)
MonNb = MonNb + 1
End If
End If
Next i 'pprochaine boucle dans tableau
If MaSom <> 0 And MonNb <> 0 Then
ThisWorkbook.Worksheets("TdB").Range("H18").Value = MaSom / MonNb
End If
Erase montableau 'réinitalise le tableau
End Sub |
Partager