Private Sub UserForm_Initialize()
Set d = CreateObject("scripting.dictionary")
For Each c In Application.Index([bd], , 1)
If c <> "" Then
temp = c.Value & c.Offset(, 6).Value
d(temp) = ""
End If
Next c
Me.ComboBox1.List = Application.Transpose(d.keys)
Me.ComboBox1.SetFocus
SendKeys "{F4}"
End Sub
Private Sub ComboBox1_Click()
liste (2) 'Si j'ai bien compris la Combobox1 et alimenter par liste (2), ou se trouve liste (2)
End Sub
Private Sub ComboBox2_Click()
liste (3)
End Sub
Private Sub ComboBox3_Click()
liste (4)
End Sub
Private Sub ComboBox4_Click()
liste (5) ' La Combobox est alimenter comment
End Sub
Sub liste(col)
Set d = CreateObject("scripting.dictionary")
For Each c In Application.Index([bd], , col)
If c.Value <> "" Then
If Left(c, col - 1) = Left(Me("ComboBox" & CStr(col - 1)), col - 1) Then 'changer pour avoir - partout ??
If Left(c.Offset(, 7 - col).Value, 3) = " - " Then
temp = c.Value & c.Offset(, 7 - col).Value
Else
temp = c.Value & " - " & c.Offset(, 7 - col).Value
End If
d(temp) = ""
End If
End If
Next c
If d.Count > 0 Then
Me("ComboBox" & CStr(col)).List = Application.Transpose(d.keys)
Me("ComboBox" & CStr(col)).SetFocus
SendKeys "{F4}"
Else
Me("ComboBox" & CStr(col)).Clear
End If
End Sub
Private Sub CommandButton1_Click()
'Pourrais-tu m'expliquer le code ci-dessous
'Dans la cellule active de la feuille "Devis"
lig = ActiveCell.Row
'Cellule( ligne, colonne 4 ??
Cells(lig, 4) = Trim(Mid(ComboBox2, 1, InStr(ComboBox2, "-") - 2))
Cells(lig, 5) = Trim(Mid(ComboBox3, InStr(ComboBox3, "-") + 2))
lig = lig + 1
Cells(lig, 4) = Trim(Mid(ComboBox4, 1, InStr(ComboBox4, "-") - 2))
Cells(lig, 5) = Trim(Mid(ComboBox5, InStr(ComboBox5, "-") + 2))
Unload Me
End Sub