Private Sub UserForm_Initialize()
Set F = Sheets("Liste")
Set mondico = CreateObject("Scripting.Dictionary")
For Each c In Range(F.[B5], F.[B800].End(xlUp))
If c.Value <> "" Then mondico.Item(c.Value) = c.Value
Next c
Me.ComboMetier.List = mondico.items
With Me.ComboArticle
.ColumnCount = 3
.ColumnWidths = "90;40;40"
End With
' Me.TxtQuantité.SetFocus
' SendKeys "{F4}"
End Sub
Private Sub ComboMetier_change()
Set F = Sheets("Liste")
Set mondico = CreateObject("Scripting.Dictionary")
i = 0
Me.ComboArticle.Clear
For Each c In Range(F.[B5], F.[B800].End(xlUp))
If c = Me.ComboMetier And c.Offset(, 1) <> "" Then
mondico.Item(c.Offset(, 1).Value) = c.Offset(, 1).Value
Me.ComboGenre.AddItem
Me.ComboGenre.List(i, 0) = c.Offset(, 1).Value
Me.ComboGenre.List(i, 1) = c.Offset(0, 2).Value
Me.ComboGenre.List(i, 2) = c.Offset(0, 3).Value
i = i + 1
End If
Next c
Me.ComboGenre.List = mondico.items
Me.ComboGenre.SetFocus
' SendKeys "{F4}"
End Sub
Private Sub ComboGenre_Change()
Set F = Sheets("Liste")
Set mondico = CreateObject("Scripting.Dictionary")
i = 0
Me.ComboArticle.Clear
For Each c In Range(F.[C5], F.[C800].End(xlUp))
If c.Offset(, -1) = Me.ComboMetier And c = Me.ComboGenre Then
Me.ComboFournisseur.AddItem
Me.ComboFournisseur.List(Me.ComboFournisseur.ListCount - 1, 0) = c.Offset(, 1).Value
Me.ComboFournisseur.List(Me.ComboFournisseur.ListCount - 1, 1) = c.Offset(0, 2).Value
Me.ComboFournisseur.List(Me.ComboFournisseur.ListCount - 1, 2) = c.Offset(0, 3).Value
End If
Next c
Me.ComboFournisseur.List = mondico.items
Me.ComboFournisseur.SetFocus
' SendKeys "{F4}"
End Sub
Private Sub ComboFournisseur_Change()
Set F = Sheets("Liste")
Set mondico = CreateObject("Scripting.Dictionary")
i = 0
Me.ComboArticle.Clear
For Each c In Range(F.[D5], F.[D800].End(xlUp))
If c.Offset(, -1) = Me.ComboMetier And c = Me.ComboGenre And c = Me.ComboFournisseur Then
Me.ComboArticle.AddItem
Me.ComboArticle.List(Me.ComboArticle.ListCount - 2, 0) = c.Offset(, 1).Value
Me.ComboArticle.List(Me.ComboArticle.ListCount - 2, 1) = c.Offset(1, 2).Value
Me.ComboArticle.List(Me.ComboArticle.ListCount - 2, 2) = c.Offset(1, 3).Value
End If
Next c
Me.ComboArticle.List = mondico.items
Me.ComboArticle.SetFocus
' SendKeys "{F4}"
End Sub
Private Sub ComboArticle_change()
If Me.ComboArticle.ListIndex > -1 Then
ActiveCell = Me.ComboMetier
ActiveCell = Me.ComboGenre
ActiveCell = Me.ComboFournisseur
ActiveCell.Offset(0) = Me.ComboArticle
End If
If Range("A9") = "" Then
Range("A9").Select
vOperationNum = 1
Else
Range("A8").End(xlDown).Select
vOperationNum = Selection.Value + 1
ActiveCell.Offset(1, 0).Range("A1").Select
End If
ActiveCell.Value = vOperationNum
ActiveCell.Offset(0, 5).Value = FrmAchats.TxtQuantité.Value
Unload Me
Range("A8").Select
End Sub