Bonjour,
Dans les nouveaux codes pour Combobox2, tu n'as pas renommé tous les éléments. Il restait des Combobox1. Il semblait y avoir des conflis avec a et mémo...
Un essai ...
Remplace tout le code par ceci ...
Dim a(), a2(), mémo, mémo2
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set zSaisie = Range("E18")
If Not Intersect(zSaisie, Target) Is Nothing And Target.Count = 1 Then
If mémo <> "" Then If IsError(Application.Match(Range(mémo), a, 0)) Then Range(mémo) = ""
a = Application.Transpose(Sheets("Chantiers_Sections").Range("Liste_chantier"))
Me.ComboBox1.List = a
Me.ComboBox1.Height = Target.Height + 3
Me.ComboBox1.Width = Target.Width
Me.ComboBox1.Top = Target.Top
Me.ComboBox1.Left = Target.Left
Me.ComboBox1 = Target
Me.ComboBox1.Visible = True
Me.ComboBox1.Activate
mémo = Target.Address
Else
Me.ComboBox1.Visible = False
End If
Set zSaisie = Range("E20")
If Not Intersect(zSaisie, Target) Is Nothing And Target.Count = 1 Then
If mémo2 <> "" Then If IsError(Application.Match(Range(mémo2), a2, 0)) Then Range(mémo2) = ""
a2 = Application.Transpose(Sheets("Fournisseurs").Range("Liste_fournisseurs"))
Me.ComboBox2.List = a2
Me.ComboBox2.Height = Target.Height + 3
Me.ComboBox2.Width = Target.Width
Me.ComboBox2.Top = Target.Top
Me.ComboBox2.Left = Target.Left
Me.ComboBox2 = Target
Me.ComboBox2.Visible = True
Me.ComboBox2.Activate
mémo = Target.Address
Else
Me.ComboBox2.Visible = False
End If
End Sub
Private Sub ComboBox1_Change()
If Me.ComboBox1 <> "" And IsError(Application.Match(Me.ComboBox1, a, 0)) Then
Set d1 = CreateObject("Scripting.Dictionary")
tmp = "*" & UCase(Me.ComboBox1) & "*"
For Each c In a
If UCase(c) Like tmp Then d1(c) = ""
Next c
Me.ComboBox1.List = d1.keys
Me.ComboBox1.DropDown
End If
ActiveCell.Value = Me.ComboBox1
End Sub
Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
ComboBox1.List = Sheets("Chantiers_Sections").Range("Liste_chantier").Value
Me.ComboBox1.DropDown
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
If IsError(Application.Match(ActiveCell, a, 0)) Then ActiveCell = ""
ActiveCell.Offset(1).Select
End If
End Sub
Private Sub ComboBox2_Change()
If Me.ComboBox2 <> "" And IsError(Application.Match(Me.ComboBox2, a2, 0)) Then
Set d1 = CreateObject("Scripting.Dictionary")
tmp = "*" & UCase(Me.ComboBox2) & "*"
For Each c In a2
If UCase(c) Like tmp Then d1(c) = ""
Next c
Me.ComboBox2.List = d1.keys
Me.ComboBox2.DropDown
End If
ActiveCell.Value = Me.ComboBox2
End Sub
Private Sub ComboBox2_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
ComboBox2.List = Sheets("Fournisseurs").Range("Liste_fournisseurs").Value
Me.ComboBox2.DropDown
End Sub
Private Sub ComboBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
If IsError(Application.Match(ActiveCell, a, 0)) Then ActiveCell = ""
ActiveCell.Offset(1).Select
End If
End Sub
ric