Option Compare Text
Dim n As Byte, Dli As Long
Private f As Worksheet 'déclare la variable f (Feuille)
Private Sub button_quitter_Click()
Unload Me
End Sub
'chargement de la listbox
Private Sub UserForm_Initialize()
Set f = Sheets("Situation") 'définit l'onglet f
Dli = f.Cells(Rows.Count, 1).End(xlUp).Row
For n = 4 To Dli
Combo_engins = f.Cells(n, 1)
If Combo_engins.ListIndex = -1 Then Combo_engins.AddItem Cells(n, 1)
Next
n = 0
Me.TextBox4 = Format(Range("E1").Value, "dddd dd mmmm yyyy")
End Sub
Private Sub Combo_engins_Change()
ListBox1.Clear
End Sub
Private Sub OptionButton1_Click()
ListBox1.Clear
If OptionButton1 Then n = 0
End Sub
Private Sub OptionButton2_Click()
ListBox1.Clear
If OptionButton2 Then n = 1
End Sub
Private Sub OptionButton3_Click()
ListBox1.Clear
If OptionButton3 Then n = 2
End Sub
Private Sub OptionButton4_Click()
ListBox1.Clear
If OptionButton4 Then n = 3
End Sub
Private Sub Button_visualiser_Click()
With ListBox1
.Clear
For l = 4 To Dli
If f.Cells(l, 1) = Combo_engins Then
Select Case n
Case 0
.AddItem f.Cells(l, 1)
For Col = 2 To 8
.List(.ListCount - 1, Col) = f.Cells(l, Col + 1)
Next
Case 1
If f.Cells(l, 7) = "en cours" Then
.AddItem Cells(l, 1)
For Col = 2 To 7
.List(.ListCount - 1, Col) = f.Cells(l, Col + 1)
Next
End If
Case 2
If f.Cells(l, 7) = "terminé" Then
.AddItem Cells(l, 1)
For Col = 2 To 7
.List(.ListCount - 1, Col) = f.Cells(l, Col + 1)
Next
End If
Case Else
If f.Cells(l, 7) = "irréparable" Then
.AddItem f.Cells(l, 1)
For Col = 2 To 7
.List(.ListCount - 1, Col) = f.Cells(l, Col + 1)
Next
End If
End Select
End If
Next
End With
End Sub
' pour alimenter la combobox en fonction des option button sélectionnés
Private Sub OptionButton_RPC_Click()
AlimCombo 1
End Sub
Private Sub OptionButton_Caudataire_Click()
AlimCombo 2
End Sub
Private Sub OptionButton_Levage_Click()
AlimCombo 3
End Sub
Private Sub OptionButtonPSS10T_Click()
AlimCombo 4
End Sub
Private Sub OptionButton_PSS4T_Click()
AlimCombo 5
End Sub
Sub AlimCombo(Cl As Integer)
Dim I As Long
Me.Combo_engins.Clear
With Sheets("données")
For I = 2 To .Cells(65536, Cl).End(xlUp).Row
Me.Combo_engins = .Cells(I, Cl)
If Me.Combo_engins.ListIndex = -1 Then
Me.Combo_engins.AddItem .Cells(I, Cl)
End If
Next I
End With
Me.Combo_engins.ListIndex = -1
End Sub