ComboBox intuitive

Fermé
ti_mouton Messages postés 143 Date d'inscription vendredi 29 mai 2015 Statut Membre Dernière intervention 5 septembre 2020 - Modifié par ti_mouton le 4/06/2015 à 16:43
f894009 Messages postés 17185 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 15 avril 2024 - 4 juin 2015 à 17:02
Bonjour,

Je suis débutante en VBA, grâce à l'aide de ce forum j'ai pu développer ce userform, je souhaiterais faire en sorte que la ComboBox 6 soit intuitive.

Dim f


Private Sub ComboBox6_Change()

End Sub

Private Sub Label1_Click()

End Sub

Private Sub Label2_Click()

End Sub

Private Sub Label3_Click()

End Sub

Private Sub Label4_Click()

End Sub

Private Sub Label5_Click()

End Sub

Private Sub Label6_Click()

End Sub

Private Sub TextBox1_Change()

End Sub

Private Sub TextBox2_Change()

End Sub

Private Sub UserForm_Initialize()
Set f = Sheets("BDD")
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
mondico(C.Value) = ""
Next C
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox1.List = temp
End Sub
Private Sub ComboBox1_click()
Me.ComboBox2.Clear
Me.ComboBox3.Clear
Me.ComboBox4.Clear
Me.ComboBox5.Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
If C = Me.ComboBox1 Then mondico(C.Offset(, 1).Value) = ""
Next C
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox2.List = temp
End Sub
Private Sub ComboBox2_click()
Me.ComboBox3.Clear
Me.ComboBox4.Clear
Me.ComboBox5.Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 Then mondico(C.Offset(, 2).Value) = ""
Next C
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox3.List = temp
End Sub
Private Sub ComboBox3_click()
Me.ComboBox4.Clear
Me.ComboBox5.Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 And C.Offset(, 2).Value = Me.ComboBox3 Then mondico(C.Offset(, 3).Value) = ""
Next C
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox4.List = temp
End Sub
Private Sub ComboBox4_click()
Me.ComboBox5.Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each C In f.Range("A3:A" & f.[A65000].End(xlUp).Row)
If C = Me.ComboBox1 And C.Offset(, 1) = Me.ComboBox2 And C.Offset(, 2).Value = Me.ComboBox3 And C.Offset(, 3).Value = Me.ComboBox4 Then mondico(C.Offset(, 4).Value) = ""
Next C
temp = mondico.keys
Call Tri(temp, LBound(temp), UBound(temp))
Me.ComboBox5.List = temp
End Sub
Sub Tri(a, gauc, droi) ' Quick sort
ref = a((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While a(g) < ref: g = g + 1: Loop
Do While ref < a(d): d = d - 1: Loop
If g <= d Then
temp = a(g): a(g) = a(d): a(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call Tri(a, g, droi)
If gauc < d Then Call Tri(a, gauc, d)
End Sub

Private Sub CommandButton1_Click()
Dim DerLig As Integer
If TextBox2 = "" Then
MsgBox "Merci de remplir le champ Déscription"
Exit Sub
End If
With Worksheets("Saisie")
DerLig = .Range("B" & Rows.Count).End(xlUp).Row + 1
.Range("C" & DerLig).Value = ComboBox1.Value
.Range("D" & DerLig).Value = ComboBox2.Value
.Range("E" & DerLig).Value = ComboBox3.Value
.Range("F" & DerLig).Value = ComboBox4.Value
.Range("G" & DerLig).Value = ComboBox5.Value
.Range("B" & DerLig).Value = ComboBox6.Value
.Range("H" & DerLig).Value = TextBox1.Value
.Range("K" & DerLig).Value = TextBox2.Value
End With

Unload UserForm1

End Sub

Merci pour votre aide.

1 réponse

f894009 Messages postés 17185 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 15 avril 2024 1 702
Modifié par f894009 le 4/06/2015 à 17:03
Bonjour,

que la ComboBox 6 soit intuitive Certes, mais pourriez-vous developper un peu plus ????
0