fonction .find renvoie à la derniere recherche

charon

XLDnaute Nouveau
Bonjour le forum,
La combobox que j'ai créé renvoie a une plage de donner, quand on selectionne une des entrées cela renvoie à la ligne désirée.
Le souci est qu'en réalité cela renvoie à la ligne de la recherche précédente.
Comment fait-on pour réinitialser la combobox? Merci de votre aide
 

charon

XLDnaute Nouveau
Re : fonction .find renvoie à la derniere recherche

Désolé, voici le code:

Private Sub UserForm_Initialize()
Dim Plage As Range

With Sheets("Liste entreprises")
Set Plage = .Range("I3:I" & .Range("I65536").End(xlUp).Row)
End With

ComboBox1.List = Plage.Value
End Sub

Private Sub CommandButton1_Click() 'bouton pour afficher des infos dans une msgbox
Sheets("Liste entreprises").Select

Dim trouve As Range, mavaleur As String
With Sheets("Liste entreprises").Range("I3:I" & Range("I65536").End(xlUp).Row)
Set trouve = .Find(what:=ComboBox1.Value, LookIn:=xlValues)
End With
If Not trouve Is Nothing Then
MsgBox "Enseigne :" & Cells(trouve.Row, trouve.Column).Text & Chr(13) & "Responsable: " & Cells(trouve.Row, 10).Text & Chr(13) & "Fonction: " & Cells(trouve.Row, 11).Text & Chr(13) & "Adresse: " & Cells(trouve.Row, 13).Text & " " & Cells(trouve.Row, 14).Text & Chr(13) & "ZA : " & Cells(trouve.Row, 12).Text & Chr(13) & "Code Postal: " & Cells(trouve.Row, 16).Value & Chr(13) & "Commune : " & Cells(trouve.Row, 17) & Chr(13) & "Téléphone : " & Cells(trouve.Row, 18).Text & Chr(13) & "Fax : " & Cells(trouve.Row, 19).Text & Chr(13) & "Mobile : " & Cells(trouve.Row, 20).Text & Chr(13) & "Courriel : " & Cells(trouve.Row, 21).Text & Chr(13) & "Site internet : " & Cells(trouve.Row, 22).Text & Chr(13) & "Numéro Siret : " & Cells(trouve.Row, 29)
End If

End Sub

Private Sub CommandButton2_Click()
'Ca c'est pour me renvoyer à la ligne de la selection

Dim trouve As Range
With Sheets("Liste entreprises").Range("I3:I" & Range("I65536").End(xlUp).Row)
Set trouve = .Find(what:=ComboBox1.Value, LookIn:=xlValues)
End With
If Not trouve Is Nothing Then
Sheets("Liste entreprises").Activate
Rows(trouve.Row).Select
UserForm1.Hide
End If

End Sub
 
C

Compte Supprimé 979

Guest
Re : fonction .find renvoie à la derniere recherche

Bonsoir Charon,

Pas constaté ce problème chez moi !?

Peut-être en effaçant les variables objet, celles appelées par Set ...
Par
Code:
Set VariableObjet = Nothing
A la fin de chaque procédure

Code:
Private Sub UserForm_Initialize()
Dim Plage As Range
With Sheets("Liste entreprises")
  Set Plage = .Range("I3:I" & .Range("I65536").End(xlUp).Row)
End With
ComboBox1.List = Plage.Value
[COLOR=blue][B]Set Plage = nothing
[/B][/COLOR]End Sub
Etc ...

A+
 

Discussions similaires

Réponses
11
Affichages
282

Statistiques des forums

Discussions
312 203
Messages
2 086 191
Membres
103 152
dernier inscrit
Karibu