Chercher un élément du tableau sur base des infos présents dans celui-ci
Bonjour à toutes et tous,
Dans la poursuite de la création d'un formulaire permettant la recherche d'informations sur base de n'importe quelle autre information présent dans le tableau, je sèche.
En effet, ce que je souhaiterai faire est la chose suivante:
Private Sub Chercher_Click()
Dim x As Long
Dim y As Long
x = Sheets("feuille matricule").Range("A" & Rows.Count).End(xlUp).Row
For y = 5 To x
If Sheets("feuille matricule").Cells(y, 2).Value = TxtChercher.Text Then
CbxCivilite = Sheets("feuille matricule").Cells(y, 1).Value
TxtNom = Sheets("feuille matricule").Cells(y, 2).Value
TxtPrenom = Sheets("feuille matricule").Cells(y, 3).Value
TxtNNational = Sheets("feuille matricule").Cells(y, 4).Value
TxtNMatricule = Sheets("feuille matricule").Cells(y, 5).Value
TxtEmail = Sheets("feuille matricule").Cells(y, 6).Value
TxtGSM = Sheets("feuille matricule").Cells(y, 7).Value
TxtTelephone = Sheets("feuille matricule").Cells(y, 8).Value
TxtNUrgence = Sheets("feuille matricule").Cells(y, 9).Value
TxtEntreeEnFonction = Sheets("feuille matricule").Cells(y, 10).Value
TxtNCompteBancaire = Sheets("feuille matricule").Cells(y, 11).Value
TxtDateNaissance = Sheets("feuille matricule").Cells(y, 12).Value
TxtLieuNaissance = Sheets("feuille matricule").Cells(y, 14).Value
TxtPaysNaissance = Sheets("feuille matricule").Cells(y, 15).Value
TxtAdresse = Sheets("feuille matricule").Cells(y, 16).Value
TxtNumero = Sheets("feuille matricule").Cells(y, 17).Value
TxtBoite = Sheets("feuille matricule").Cells(y, 18).Value
TxtCodePostal = Sheets("feuille matricule").Cells(y, 19).Value
TxtCommune = Sheets("feuille matricule").Cells(y, 20).Value
CbxEtatCivil = Sheets("feuille matricule").Cells(y, 21).Value
TxtNomConjoint = Sheets("feuille matricule").Cells(y, 22).Value
TxtPrenomConjoint = Sheets("feuille matricule").Cells(y, 23).Value
TxtPaysNaissanceConjoint = Sheets("feuille matricule").Cells(y, 24).Value
TxtDateNaissanceConjoint = Sheets("feuille matricule").Cells(y, 25).Value
TxtLieuNaissanceConjoint = Sheets("feuille matricule").Cells(y, 26).Value
TxtGSMConjoint = Sheets("feuille matricule").Cells(y, 27).Value
TxtCombienEnfants = Sheets("feuille matricule").Cells(y, 28).Value
CbxEnfantACharge = Sheets("feuille matricule").Cells(y, 29).Value
CbxNiveauDiplome = Sheets("feuille matricule").Cells(y, 30).Value
CbxDenominationDiplome = Sheets("feuille matricule").Cells(y, 31).Value
TxtDateDiplome = Sheets("feuille matricule").Cells(y, 32).Value
TxtEcoleDiplome = Sheets("feuille matricule").Cells(y, 33).Value
TxtDatePrestation = Sheets("feuille matricule").Cells(y, 34).Value
End if
Next y
End Sub
Je souhaiterai qu'une personne puisse faire une recherche d'après un élément auparavant inséré dans ce tableau.
Comment puis-je faire?
Vous trouverez mon projet dans le fichier que je joins à ma question.
Merci!
Bonjour
commence déjà par mettre les end if qui manquent. 5 If successifs et un seul end if à la fin. Ca ne peut que planter
Merci Yal_excel. Je suis novice en la matière et je dois reconnaître aussi que je ne vois pas où il manque les end if. Afin que je puisse apprendre de mes erreurs, pourrais-tu me montrer où j'aurais dû les mettre?
Merci! 🙂
Regardes le fichier que je t'ai envoyé. J'ai corrigé la macro Chercher_Click() et elle fonctionne. J'en ai aussi profité pour modifier un peu ta texbox texte à chercher. Je trouvais que devoir vider la boite avant de pouvoir saisir ce qu'on veut c'est pas très fonctionnel.