Re : Problème avec fonction rechercheh en vba
Bonjour,
Ci-joint une version un lightée qui gére le pb de ta liste :
Je l'ai mis dans userform_initialize. Normalement la boit n'est initialisée qu'une fois, ça économise du code
J'ai également enlevé les TextBox_volume_ILN.Enabled et ai traité le pb avec des If.
Les TextBox_volume_ILN.Enabled sécurisent la saisie mais l'utilisateur peut ne pas comprendre ce qui se passe.
Ou bien j'utiliserai plutot TextBox_volume_ILN.Visible. Ca apparait quand on choisit.
Option Explicit
Private Sub userform_initialize()
Dim c
For Each c In Rows(16).SpecialCells(xlCellTypeConstants, 23)
If c.Value <> "" Then ComboBox_ILN_choisis.AddItem c.Value
Next
End Sub
Private Sub ajouter_volume_ILN_Click()
Dim PlageILN2 As Range
Dim RangeObj As Range
If ComboBox_ILN_choisis = "" Then MsgBox "Il faut selectionner une valeur": Exit Sub
With Sheets("Synthèse")
Set PlageILN2 = .Range(.Cells(16, 2), .Cells(16, .Cells(17, 256).End(xlToLeft).Column))
End With
Set RangeObj = PlageILN2.Find(What:=ComboBox_ILN_choisis.Text, LookIn:=xlValues, LookAt:=xlPart)
If RangeObj Is Nothing Then
MsgBox "ILN non ajouté, veuillez le créer dans le formulaite variable générale"
Else
If TextBox_volume_ILN = "" Then MsgBox "Il n'y a pas de volume saisi !" Else RangeObj.Offset(2, 0).Value = TextBox_volume_ILN
End If
End Sub
Sinon, tu peux aussi faire comme ceci pour la liste :
Dim c
ComboBox_ILN_choisis.Clear
For Each c In Rows(16).SpecialCells(xlCellTypeConstants, 23)
If c.Value <> "" Then ComboBox_ILN_choisis.AddItem c.Value
Next
NB - tu ne déranges personne.
Le principe du forum c'est justement de pouvoir choisir les sujets auxquels on répond