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
| Sub test()
Dim FOUND_SUIVI As Boolean 'variable boolean si suivi ouvert
Dim FOUND_ARCHIVE As Boolean 'variable boolean si archives ouvert
Dim Workbook_SUIVI As Workbook 'varaible pour passer les classeurs ouvert et trouver suivi lot
Dim Workbook_ARCHIVE As Workbook 'varaible pour passer les classeurs ouverts et trouver archives
Dim i As Long 'variable du tableau
Dim DL_SUIVI As Long 'derniere ligne suivi lot
Dim DL_ARCHIVE As Long 'derniere ligne archives
Dim CPT As Long 'compteur de lot trouvés
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
DL_SUIVI = Workbooks("SUIVI_LOTS1.xls").Worksheets("Liste T&F").Cells(Rows.Count, 3).End(xlUp).Row + 1
'DL_ARCHIVE = Workbooks("Archives.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
'For i = 3 To DL_SUIVI
'If Year(Workbooks("SUIVI_LOTS1.xls").Worksheets("Liste T&F").Cells(i, 17).Value) & DatePart("ww", Workbooks("SUIVI_LOTS1.xls").Worksheets("Liste T&F").Cells(i, 17).Value) = Then
Dim montableau() As Variant
montableau() = Workbooks("SUIVI_LOTS1.xls").Worksheets("Liste T&F").Range("A3:Q" & DL_SUIVI).Value
For j = 3 To L
For i = LBound(montableau, 17) To UBound(montableau, 17)
If Year(montableau(i, 17)) & DatePart("ww", montableau(i, 17)) = ThisWorkbook.Worksheets("Liste").Cells(j, 1).Value Then
CPT = CPT + 1
End If
Next i
ThisWorkbook.Worksheets("TdB").Range("C" & j).Value = CPT
Next j
Erase montableau
MsgBox CPT
End Sub |
Partager