Private Sub UserForm_Initialize()
cbocatégorie.List = Application.Transpose(Range("Categories"))
cboagence.List = Application.Transpose(Range("Agences"))
End Sub
Private Sub cbocatégorie_change()
Dim nc As Long, nl As Long
cbooutillage.Clear
If Not cbocatégorie.ListIndex = -1 Then
nc = Application.WorksheetFunction.Match(cbocatégorie.Text, Range("Categories"), 0) + 1
With Worksheets("Liste")
nl = .Cells(Rows.Count, nc).End(xlUp).Row
On Error GoTo Err01
cbooutillage.List = .Range(.Cells(3, nc), .Cells(nl, nc)).Value
End With
cbooutillage.SetFocus
Exit Sub
End If
Err01:
cbooutillage.AddItem Worksheets("Liste").Cells(3, nc)
cbooutillage.SetFocus
End Sub
Private Sub cboagence_Change()
Dim nc As Long, nl As Long
cbonom.Clear
If Not cboagence.ListIndex = -1 Then
nc = Application.WorksheetFunction.Match(cboagence.Text, Range("Agences"), 0) + 7
With Worksheets("Liste")
nl = .Cells(Rows.Count, nc).End(xlUp).Row
On Error GoTo Err02
cbonom.List = .Range(.Cells(3, nc), .Cells(nl, nc)).Value
End With
cbonom.SetFocus
End If
Exit Sub
Err02:
cbonom.AddItem Worksheets("Liste").Cells(3, nc)
cbonom.SetFocus
End Sub