Exit sub

Résolu/Fermé
odinateurs! - 5 mai 2016 à 09:42
 odinateurs! - 5 mai 2016 à 11:23
Bonjour,


Merci de m'aider a faire cette macro
B1 a B10 contient des noms
si le code nom= InputBox("introduire Nom ") ne trouve dans la liste des noms B1 a B10
msgbox ("pas trouve")
then exit sub
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
nom = InputBox("introduire Nom ")


ligne = Sheets("Feuil1").[B:B].Find(nom, LookIn:=xlValues).Row

Me.nom = Sheets("Feuil1").Cells(ligne, 2)
Me.prenom = Sheets("Feuil1").Cells(ligne, 3)
ville = Sheets("Feuil1").Cells(ligne, 4)

End Sub

2 réponses

f894009 Messages postés 17185 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 15 avril 2024 1 701
5 mai 2016 à 10:41
Bonjour,

une facon de faire:

    Dim ligne
    
    snom = InputBox("introduire Nom ")
    Set ligne = Sheets("Feuil1").[B:B].Find(snom, LookIn:=xlValues)
    If Not ligne Is Nothing Then
        nom = Sheets("Feuil1").Cells(ligne.Row, 2)
        prenom = Sheets("Feuil1").Cells(ligne.Row, 3)
        ville = Sheets("Feuil1").Cells(ligne.Row, 4)
    End If
0
Bonjour,

Encore une fois merci beaucoup
0