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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
| Option Explicit
Dim Ws As Worksheet
Dim NbLignes As Integer
Private Sub ComboBox4_Change() 'combobox sous produit
Dim plage As Range
Set plage = Sheets("LISTE").Range("G2:F20")
End Sub
Private Sub ComboBox5_Change() 'Combobox activité
Dim plage As Range
Set plage = Sheets("LISTE").Range("A2:A90")
End Sub
Private Sub ComboBox3_Change() 'Combobox produit
Dim plage As Range
Set plage = Sheets("LISTE").Range("F2:F99")
End Sub
Private Sub ComboBox6_Change() 'Combobox intervenant
Dim plage As Range
Set plage = Sheets("LISTE").Range("E2:E15")
End Sub
Private Sub ComboBox7_Change() 'Combobox bateaux
If ComboBox7.Value = "" Then Exit Sub
Dim NomRange As String
NomRange = CaracSpec(ComboBox7.Value)
End Sub
Private Sub CommandButton1_Click()
Unload UserForm1
End Sub
Private Sub CommandButton2_Click()
'Recuperation de la derniere ligne et inscription des données
Dim intLine As Integer
intLine = Range("a65000").End(xlUp).Row + 1
Cells(intLine, 1).Value = TextBox2.Value
Cells(intLine, 2).Value = ComboBox1.Value
Cells(intLine, 3).Value = ComboBox2.Value
Cells(intLine, 4).Value = ComboBox3.Value
Cells(intLine, 5).Value = ComboBox4.Value
Cells(intLine, 6).Value = ComboBox5.Value
Cells(intLine, 7).Value = ComboBox6.Value
Cells(intLine, 8).Value = TextBox1.Value
Cells(intLine, 13).Value = TextBox4.Value
Cells(intLine, 14).Value = TextBox5.Value
intLine = Sheets("DONNEES " & ComboBox6.Value).Range("a65000").End(xlUp).Row + 1
With Sheets("DONNEES " & ComboBox6.Value)
.Cells(intLine, 1).Value = TextBox2.Value
.Cells(intLine, 2).Value = ComboBox1.Value
.Cells(intLine, 3).Value = ComboBox2.Value
.Cells(intLine, 4).Value = ComboBox3.Value
.Cells(intLine, 5).Value = ComboBox4.Value
.Cells(intLine, 6).Value = ComboBox5.Value
.Cells(intLine, 7).Value = ComboBox6.Value
.Cells(intLine, 8).Value = TextBox1.Value
End With
End Sub
Private Sub ListBox1_Click()
End Sub
Private Sub Label10_Click()
End Sub
Private Sub Label13_Click()
End Sub
Private Sub Label7_Click()
End Sub
Private Sub UserForm_Initialize()
'Définit la feuille contenant les données
Set Ws = Worksheets("client_bateaux2")
'Définit le nombre de lignes dans la colonne A
NbLignes = Ws.Range("A65536").End(xlUp).Row
'Remplissage du ComboBox1
Alim_Combo 1
End Sub
Private Sub Label1_Click()
End Sub
Private Sub Label5_Click()
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub ComboBox1_Change() 'Combobox client
'Remplissage Combo2
Alim_Combo 2, ComboBox1.Value
End Sub
'Procédure pour alimenter les ComboBox
Private Sub Alim_Combo(CbxIndex As Integer, Optional Cible As Variant)
Dim j As Integer
Dim Obj As Control
'Définit le ComboBox à remplir
Set Obj = Me.Controls("ComboBox" & CbxIndex)
'Supprime les anciennes données
Obj.Clear
'alimente le Combobox initial (Combobox1)
If CbxIndex = 1 Then
'Boucle sur les lignes de la colonne A (à partir de la 2eme ligne)
For j = 2 To NbLignes
Obj = Ws.Range("A" & j)
'Remplit le ComboBox sans doublons
If Obj.ListIndex = -1 Then Obj.AddItem Ws.Range("A" & j)
Next j
Else
'Alimentation conditionnelle des autres Combobox en fonction de
'ce qui est sélectionnée dans le contrôle précédent:
'(La sélection du ComboBox1 définit le contenu du ComboBox2,
For j = 2 To NbLignes
If Ws.Range("A" & j).Offset(0, CbxIndex - 2) = Cible Then
Obj = Ws.Range("A" & j).Offset(0, CbxIndex - 1)
If Obj.ListIndex = -1 Then Obj.AddItem Ws.Range("A" & j).Offset(0, CbxIndex - 1)
End If
Next j
End If
'Enlève la sélection dans le ComboBox
Obj.ListIndex = -1
End Sub
Private Sub ComboBox2_click()
End Sub |
Partager