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
| Option Explicit
Sub ShowForm()
Dim Row As ListRow
With UserForm1
.cboTool.List = Range("t_Machines[Machine]").Value
.Show
If .Result = "Validate" Then
Set Row = Range("t_Pannes").ListObject.ListRows.Add()
Row.Range(1).Value = .cboTool.Value
Row.Range(2).Value = .cboBreakDown.Value
Row.Range(3).Value = .getType()
Row.Range(4).Value = CDate(.tbaDate.Value)
Row.Range(5).Value = .tboWorker.Value
End If
End With
Unload UserForm1
End Sub
Function getBreakDownTypes(Tool As String, Optional BreakDownType As String) As Variant
ReDim Values(0 To 0) As Variant
Dim Value As String
Dim r As Range
For Each r In Range("t_PannesTypes[Machine]")
Value = ""
If r.Value = Tool Then
If BreakDownType = "" Then
Value = r(1, 2).Value
ElseIf BreakDownType = r(1, 3).Value Then
Value = r(1, 2).Value
End If
If Value <> "" Then
If Not IsEmpty(Values(0)) Then ReDim Preserve Values(0 To UBound(Values) + 1)
Values(UBound(Values)) = Value
End If
End If
Next
getBreakDownTypes = Values
End Function |
Partager