Recherche grace à la 1ere colonne

ccfconsulting

XLDnaute Junior
Bonjour,

J'ai creer un userform qui me rempli un tableau au fur a mesure et l'un en dessous de l'autre.
La 1ere colonne a un chiffre unique 1 - 2 - 3 etc
J'aimerai pouvoir modifier une ligne grace à ces numéro (ouverture d'un userform grace à un bouton "modifier" puis avec un combox selectionner un numéro et automatiquement tout les champs du userform se remplisse avec les donnée associé au numéro de ligne.

En gros ca me prend donc 1feuille et 1 userform.

Je ne sait pas mettre le fichier en ligne.....

J'espère trouver ma solution!:)

-----------------------------------
Jai trouvez ce code qui marche trés bien :
Private Sub ComboBoxmodifpartenaire_Change()
Set c = Sheets("Partenaire").Columns(1).Find(ComboBoxmodifpartenaire, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
txtorganisme = c.Offset(0, 0)
ComboBoxcompetence = c.Offset(0, 1)
txtnom = c.Offset(0, 2)
txtprenom = c.Offset(0, 3)
txttel = c.Offset(0, 4)
txtfax = c.Offset(0, 5)
txtmail = c.Offset(0, 6)
txtadresse = c.Offset(0, 7)
txtcodepostal = c.Offset(0, 8)
txtville = c.Offset(0, 8)
End If
End Sub

seulement, j'aimerais maintenant qu'il remplace la ligne concerné car quand je valide la modif , il enregistre dans une nouvelle ligne en fait je ne sait pas du tout quoi mettre dans ce bouton :valide la modif

Merci d'avance à tous
 
Dernière édition:

roro69

XLDnaute Impliqué
Re : Recherche grace à la 1ere colonne

Bonsoir mets un bouton de commane nomme le CmdEditer et insère ce code(mais sans fichier!!:D )))

Private Sub CmdEditer_Click()
'Mode édition
Dim c As Range
On Error GoTo erreur
Set c = Sheets("Partenaire").Columns(1).Find(ComboBoxmodif partenaire, LookIn:=xlValues, lookat:=xlWhole)

If c Is Nothing Then GoTo erreur
With c
.Cells(1, 0) = txtorganisme
.Cells(1, 1) = ComboBoxcompetence
.Cells(1, 2) = txtnom
.Cells(1, 3) = txtprenom
.Cells(1, 4) = txttel
.Cells(1, 5) = txtfax
.Cells(1, 6) = txtmail
.Cells(1, 7) = txtadresse
.Cells(1, 8) = txtcodepostal
.Cells(1, 9) = txtville
End With

Exit Sub
erreur:
Beep

End Sub
A++
 

ccfconsulting

XLDnaute Junior
Re : Recherche grace à la 1ere colonne

Rebonjour et merci pour le coup de main.

Mais quand je clique sur le bouton pour valider la modif il ne se passe rien (j'ai rennomé le nom du bouton comme ci dessus mais rien).

N'y aurait il pas une erreur sur le code ?, j'ai essaié avec unload me à la fin mais ca ferme l'userform sans enregistré

Voici l'enssemble de mon code sur cette userform
Merci beaucoup!!:D

Private Sub cmdAnnulepartenaire_Click()
Unload Me
End Sub



Private Sub CmdEditer_Click()
'Mode édition
Dim c As Range
On Error GoTo erreur
Set c = Sheets("Partenaire").Columns(1).Find(ComboBoxmodifpartenaire, LookIn:=xlValues, lookat:=xlWhole)

If c Is Nothing Then GoTo erreur
With c
.Cells(1, 0) = txtorganisme
.Cells(1, 1) = ComboBoxcompetence
.Cells(1, 2) = txtnom
.Cells(1, 3) = txtprenom
.Cells(1, 4) = txttel
.Cells(1, 5) = txtfax
.Cells(1, 6) = txtmail
.Cells(1, 7) = txtadresse
.Cells(1, 8) = txtcodepostal
.Cells(1, 9) = txtville
End With

Exit Sub
erreur:
Beep

End Sub

Private Sub cmdValidepartenaire_Click()
Dim Derli As Byte 'changer le type en fonction du nombre de lignes
With Sheets("Partenaire")
Derli = .[A256].End(xlUp).Row + 1
.Cells(Derli, 1) = txtorganisme
.Cells(Derli, 2) = ComboBoxcompetence
.Cells(Derli, 3) = txtnom
.Cells(Derli, 4) = txtprenom
.Cells(Derli, 5) = txttel
.Cells(Derli, 6) = txtfax
.Cells(Derli, 6) = txtmail
.Cells(Derli, 7) = txtcodepostal
.Cells(Derli, 8) = txtville
Unload Me
End With
End Sub

Private Sub ComboBoxmodifpartenaire_Change()
Set c = Sheets("Partenaire").Columns(1).Find(ComboBoxmodifpartenaire, LookIn:=xlValues, lookat:=xlWhole)
If Not c Is Nothing Then
txtorganisme = c.Offset(0, 0)
ComboBoxcompetence = c.Offset(0, 1)
txtnom = c.Offset(0, 2)
txtprenom = c.Offset(0, 3)
txttel = c.Offset(0, 4)
txtfax = c.Offset(0, 5)
txtmail = c.Offset(0, 6)
txtadresse = c.Offset(0, 7)
txtcodepostal = c.Offset(0, 8)
txtville = c.Offset(0, 8)
End If
End Sub