Mise à jour données

damdamdeo44 Messages postés 6 Statut Membre -  
Le Pingou Messages postés 12714 Date d'inscription   Statut Contributeur Dernière intervention   -
Bonjour,

je viens vers vous pour ce probleme. j'ai un userform de recherche qui m'affciche les infos en fonction des cellule. pui je les modifie ou les compléte. mais lorsque je veux cliquer sur "modifier/enregistrer" la macro modifi toujours que la dernière ligne même si c'est la première ligen que je veux modifier. et j'ai beau chercher je ne vosi pas où ça coince. pour vosu aider voici le code du clic modif.

merci

Private Sub Enregistrer_Click()
Dim Plage As range, cell As range
Dim Recherche As String, Adresse As String
Dim Ligne As Integer, n As Integer
Dim C As range

Recherche = Me.NC.Text
range("G8").Select
Ligne = Sheets("Suivi NC").range("G" & "65536").End(xlUp).Row
Set Plage = Sheets("Suivi NC").range("G" & "8:" & "G" & Ligne)
With Plage
Set C = .Find(Recherche, , xlValues, xlWhole)
'C.Select

If Not C Is Nothing Then
Adresse = C.Address
'Do

If UCase(Recherche) = UCase(Left(C, Len(Recherche))) Then

Sheets("Suivi NC").range("A" & Ligne).Value = Me.MSN.Text
Sheets("Suivi NC").range("B" & Ligne).Value = Me.STD.Text
Sheets("Suivi NC").range("C" & Ligne).Value = Me.VERSION.Text
Sheets("Suivi NC").range("D" & Ligne).Value = Me.DEPART.Text
Sheets("Suivi NC").range("E" & Ligne).Value = Me.TRONCON.Text
Sheets("Suivi NC").range("F" & Ligne).Value = Me.Tforma.Text
Sheets("Suivi NC").range("G" & Ligne).Value = Me.NC.Text
Sheets("Suivi NC").range("H" & Ligne).Value = Me.Statuts.Text
Sheets("Suivi NC").range("I" & Ligne).Value = Me.RespNC.Text
Sheets("Suivi NC").range("J" & Ligne).Value = Me.AMAerolia.Text
Sheets("Suivi NC").range("K" & Ligne).Value = Me.DEROaerolia.Text
Sheets("Suivi NC").range("L" & Ligne).Value = Me.ATA.Text
Sheets("Suivi NC").range("M" & Ligne).Value = Me.CI.Text
Sheets("Suivi NC").range("N" & Ligne).Value = Me.Zone.Text
Sheets("Suivi NC").range("O" & Ligne).Value = Me.cadre.Text
Sheets("Suivi NC").range("P" & Ligne).Value = Me.youlisse.Text
Sheets("Suivi NC").range("Q" & Ligne).Value = Me.comment.Text
Sheets("Suivi NC").range("R" & Ligne).Value = Me.DQN.Text
Sheets("Suivi NC").range("S" & Ligne).Value = Me.DERO.Text
Sheets("Suivi NC").range("T" & Ligne).Value = Me.NDQN.Text
Sheets("Suivi NC").range("U" & Ligne).Value = Me.datecrea.Text
Sheets("Suivi NC").range("V" & Ligne).Value = Me.Redact.Text
Sheets("Suivi NC").range("w" & Ligne).Value = Tdatemaj.Value
Sheets("Suivi NC").range("x" & Ligne).Value = Me.avleader.Text

End If

'Set C = .FindNext(C)
'Loop While Not C Is Nothing And C.Address <> Adresse
End If
End With
End Sub

A voir également:

1 réponse

Le Pingou Messages postés 12714 Date d'inscription   Statut Contributeur Dernière intervention   1 467
 
Bonjour,
Au passage, votre ligne d'instruction :
Ligne = Sheets("Suivi NC").range("G" & "65536").End(xlUp).Row
trouve la dernière ligne ce qui est correct.

Par contre on ne sait pas qu'elle est la ligne qu'il faut modifier, vous ne l'indiquez pas !


Salutations.
Le Pingou
0