Erreur compilation procédure trop grande

Bonjour,

Je rencontre un nouveau problème.

Je fais une répétition dans mes codes. Bien sûr, Excel me dit que c'est une erreur compilation et que la procédure est trop grande.

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, 1).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
    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
    If Sheets("feuille matricule").Cells(y, 3).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

J'ai mis 3 fois les procédures, mais je dois encore le faire 31 fois.

Pourriez-vous m'aider ?

Merci!

Bonjour, je dois reconnaitre que la méthode me dépasse aussi.

Exemple If Sheets("feuille matricule").Cells(y, 1).Value = TxtChercher.Text Then

Si le texte cherchcé est égale à la ligne y + colonne 1 ? soit Civilité ? vous allez vraiement chercher dans votre base :

Madame ou Monsieur ???

Vous auriez du ajouter un élément unique à vos saisie en colonne 1 exemple un numéro de matricule.

Ensuite vous pourrez utilisez une combox pour selectionner le matricule à modifier.

Sinon vous pouvez toujours créér une combobox qui sera alimenté par la colonne B "Nom"

(Même si celà n'évite pas les homonymes) ; ceci vous permettra de retrouver plus facilement la ligne à modifier

avec "combobox.listindex".

Merci Xmenpl.

Je tente de créer un formulaire pour mes collègues. N'y a t-il pas la possibilité de simplement raccourcir la procédure?

Bonne journée,

Non beaucoup trop compliqué et à la moindre différence de saisie dans la recherche Excel ne va pas trouver et vous penserez

que la personne n'est pas saisie alors quelle existe mais avec un accent ou une majuscule qui est différente.

Rechercher des sujets similaires à "erreur compilation procedure trop grande"