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
| Private Sub TextBoxFDNumber_Change()
ColumnMDBCreationDate = 2
ColumnMDBCreationHour = 3
ColumnMDBSchedID = 4
ColumnMDBCreatedBy = 5
ColumnMDBMachineNumber = 6
ColumnMDBFDNumber = 7
ColumnMDBOPShift = 8
ColumnMDBProductionWeight = 9
ColumnMDBAccumulatedWeight = 10
ColumnMDBUpdateDate = 11
ColumnMDBUpdateHour = 12
ColumnMDBUpdatedBy = 13
ColumnMDBCompleteDate = 14
ColumnMDBCompleteHour = 15
ColumnMDBCompletedBy = 16
ColumnMDBStatus = 17
ColumnMDBReasonToChange = 18
ColumnMDBRemark = 19
ColumnFDDIssueDate = 2
ColumnFDDIssueHour = 3
ColumnFDDSchedID = 4
ColumnFDDMachineNumber = 5
ColumnFDDOperationSize = 6
ColumnFDDFDType = 7
ColumnFDDAccumulatedWeight = 8
ColumnFDDFDNumber = 9
ColumnFDDCompleteDate = 10
ColumnFDDCompleteHour = 11
ColumnFDDCompletedBy = 12
ColumnFDDStatus = 13
ColumnFDDReasonToChange = 14
ColumnFDDRemark = 15
ColumnFDDLocation = 16
ColumnAAfficherLine = 53
ColumnAAfficherDate = 54
ColumnAAfficherShift = 55
ColumnAAfficherProductionWeight = 56
ColumnAAfficherBalanceWeight = 57
ColumnAAfficherRemark = 58
ColumnAAfficherCreatedBy = 59
ColumnAAfficherUpdatedBy = 60
If Machine_final_dies.ComboBoxMonitoringPeriod.Text = "Past 2 weeks" Then
DateLimite = DateValue(Format(DateSerial(Year(Date), Month(Date), Day(Date)) - 14, "dd/mm/yyyy"))
ElseIf Machine_final_dies.ComboBoxMonitoringPeriod.Text = "Last month" Then
DateLimite = DateValue(Format(DateSerial(Year(Date), Month(Date) - 1, Day(Date)), "dd/mm/yyyy"))
ElseIf Machine_final_dies.ComboBoxMonitoringPeriod.Text = "Past 2 months" Then
DateLimite = DateValue(Format(DateSerial(Year(Date), Month(Date) - 2, Day(Date)), "dd/mm/yyyy"))
ElseIf Machine_final_dies.ComboBoxMonitoringPeriod.Text = "Past 6 months" Then
DateLimite = DateValue(Format(DateSerial(Year(Date), Month(Date) - 6, Day(Date)), "dd/mm/yyyy"))
ElseIf Machine_final_dies.ComboBoxMonitoringPeriod.Text = "Last year" Then
DateLimite = DateValue(Format(DateSerial(Year(Date), Month(Date), Day(Date)) - 365, "dd/mm/yyyy"))
End If
'On attibue à derligne la dernière ligne du tableau "MainDatabase"
derligne = ThisWorkbook.Worksheets("MainDatabase").Range("G" & Rows.Count).End(xlUp).Row
derligne2 = ThisWorkbook.Worksheets("MainDatabase").Range("BA" & Rows.Count).End(xlUp).Row
derligne3 = ThisWorkbook.Worksheets("FDdatabase").Range("B" & Rows.Count).End(xlUp).Row
'On remplit la case size
For j = 7 To derligne3
If ThisWorkbook.Worksheets("FDdatabase").Cells(j, ColumnFDDFDNumber).Value = Me.TextBoxFDNumber Then
If ThisWorkbook.Worksheets("FDdatabase").Cells(j, ColumnFDDMachineNumber).Value = Machine_final_dies.ComboBoxMachineNumber.Text Then
Me.TextBoxFDSize.Value = ThisWorkbook.Worksheets("FDdatabase").Cells(j, ColumnFDDOperationSize).Value
End If
End If
Next j
' On remplit la case target
'Me.TextBoxFDTarget.Value = 8.9 * 8900 * (3.14159265358979 / 4) * (CDbl(Me.TextBoxFDSize.Value)) * (CDbl(Me.TextBoxFDSize.Value))
' ON prepare le tableau que l'on fera ensuite afficher dans les listboxs
ThisWorkbook.Worksheets("MainDatabase").Range("BA3:BH" & derligne2).ClearContents
ThisWorkbook.Worksheets("MainDatabase").Cells(2, ColumnAAfficherLine).Value = "N"
ThisWorkbook.Worksheets("MainDatabase").Cells(2, ColumnAAfficherDate).Value = "Date"
ThisWorkbook.Worksheets("MainDatabase").Cells(2, ColumnAAfficherShift).Value = "Shift"
ThisWorkbook.Worksheets("MainDatabase").Cells(2, ColumnAAfficherProductionWeight).Value = "Production Weight"
ThisWorkbook.Worksheets("MainDatabase").Cells(2, ColumnAAfficherBalanceWeight).Value = "Balance Weight"
ThisWorkbook.Worksheets("MainDatabase").Cells(2, ColumnAAfficherRemark).Value = "Remark"
ThisWorkbook.Worksheets("MainDatabase").Cells(2, ColumnAAfficherCreatedBy).Value = "Created by"
ThisWorkbook.Worksheets("MainDatabase").Cells(2, ColumnAAfficherUpdatedBy).Value = "Updated By"
'On affiche les titres dans la premiere toolbox
TabTemp2 = ThisWorkbook.Worksheets("MainDatabase").Range("BA2:BH2").Value
ListBoxtColumnTitles.ColumnCount = 8
ListBoxtColumnTitles.List() = TabTemp2
'On parcourt notre tableau afin de selectionner les infos concernant la final dies selectionnee
Verification = 0
ligne = 1
ProductionWeight = 0
For i = 4 To derligne
derligne2 = ThisWorkbook.Worksheets("MainDatabase").Range("BA" & Rows.Count).End(xlUp).Row + 1
If ThisWorkbook.Worksheets("MainDatabase").Cells(i, ColumnMDBFDNumber).Value = Me.TextBoxFDNumber.Text Then
If DateDiff("d", DateLimite, DateValue(Format(ThisWorkbook.Worksheets("MainDatabase").Cells(i, ColumnMDBCreationDate).Value, "dd/mm/yyyy"))) > 0 Then
If ThisWorkbook.Worksheets("MainDatabase").Cells(i, ColumnMDBMachineNumber).Value = Machine_final_dies.ComboBoxMachineNumber.Text Then
ThisWorkbook.Worksheets("MainDatabase").Cells(derligne2, ColumnAAfficherLine).Value = ligne
ThisWorkbook.Worksheets("MainDatabase").Cells(derligne2, ColumnAAfficherDate).Value = ThisWorkbook.Worksheets("MainDatabase").Cells(i, ColumnMDBCreationDate).Value
ThisWorkbook.Worksheets("MainDatabase").Cells(derligne2, ColumnAAfficherShift).Value = ThisWorkbook.Worksheets("MainDatabase").Cells(i, ColumnMDBOPShift).Value
ThisWorkbook.Worksheets("MainDatabase").Cells(derligne2, ColumnAAfficherProductionWeight).Value = ThisWorkbook.Worksheets("MainDatabase").Cells(i, ColumnMDBProductionWeight).Value
ThisWorkbook.Worksheets("MainDatabase").Cells(derligne2, ColumnAAfficherBalanceWeight).Value = ThisWorkbook.Worksheets("MainDatabase").Cells(i, ColumnMDBAccumulatedWeight).Value
ThisWorkbook.Worksheets("MainDatabase").Cells(derligne2, ColumnAAfficherRemark).Value = ThisWorkbook.Worksheets("MainDatabase").Cells(i, ColumnMDBRemark).Value
ThisWorkbook.Worksheets("MainDatabase").Cells(derligne2, ColumnAAfficherCreatedBy).Value = ThisWorkbook.Worksheets("MainDatabase").Cells(i, ColumnMDBCreatedBy).Value
ThisWorkbook.Worksheets("MainDatabase").Cells(derligne2, ColumnAAfficherUpdatedBy).Value = ThisWorkbook.Worksheets("MainDatabase").Cells(i, ColumnMDBUpdatedBy).Value
ligne = ligne + 1
Verification = 1
ProductionWeight = ProductionWeight + ThisWorkbook.Worksheets("MainDatabase").Cells(i, ColumnMDBProductionWeight).Value
End If
End If
End If
Next i
'Si aucune final dies ne correspond au criteres selectionnes on affiche un message d'erreur
If Verification = 0 Then
MsgBox "No more information has been found in the machine " + Machine_final_dies.ComboBoxMachineNumber + " for the dies : " + Me.TextBoxFDNumber
Exit Sub
End If
derligne2 = ThisWorkbook.Worksheets("MainDatabase").Range("BA" & Rows.Count).End(xlUp).Row
'Chargement d'une plage de cellules dans la variable TabTemp
TabTemp = ThisWorkbook.Worksheets("MainDatabase").Range("BA3:BH" & derligne2).Value
'Définit le nombre de colonnes pour la ListBox.
ListBoxData.ColumnCount = 8
'Chargement des tableau dans les ListBox
ListBoxData.List() = TabTemp |