Incermentation ligne suite a validation userform

Résolu/Fermé
cedric0715 Messages postés 210 Date d'inscription mercredi 25 février 2015 Statut Membre Dernière intervention 6 mai 2018 - 13 janv. 2017 à 09:49
cedric0715 Messages postés 210 Date d'inscription mercredi 25 février 2015 Statut Membre Dernière intervention 6 mai 2018 - 13 janv. 2017 à 10:41
Bonjour,

j ai un problème sur l’incrémentation d'un numéro dans ma colonne a des lors que je valide mon userform
mais cela me met un erreur
pouvez vous m'aider ci dessous le Code
Option Explicit

Private Sub CommandButton1_Click()
Dim NewLig As Long, c As Range, i As Long
With Sheets("suivi DI")

NewLig = Range("A65536").End(xlUp).Row + 1

i = 0
For Each c In NewLig
c = i
i = i + 1
Next c

End With
Range("a" & NewLig).Value = i
Range("B" & NewLig).Value = ComboBox1
Range("C" & NewLig).Value = ComboBox2
Range("D" & NewLig).Value = ComboBox3
Range("E" & NewLig).Value = ComboBox4
Range("F" & NewLig).Value = TextBox1
Range("G" & NewLig).Value = ComboBox5
Range("H" & NewLig).Value = TextBox2
Range("I" & NewLig).Value = TextBox3
Unload UserForm1
End Sub


merci par avance
A voir également:

1 réponse

gbinforme Messages postés 14946 Date d'inscription lundi 18 octobre 2004 Statut Contributeur Dernière intervention 24 juin 2020 4 684
Modifié par gbinforme le 13/01/2017 à 10:23
Bonjour,

C'est quoi ce code :
For Each c In NewLig
c = i
i = i + 1
Next c

Tu ne peux rien obtenir puisque NewLig n'est qu'un numéro de ligne.
En supprimant cela devrait mieux fonctionner et tu remplace ainsi :
Range("a" & NewLig).Value = Application.WorksheetFunction.Max(Range("A:A")) + 1

 Toujours zen
La perfection est atteinte, non pas lorsqu'il n'y a plus rien à ajouter, mais lorsqu'il n'y a plus rien à retirer.  Antoine de Saint-Exupéry
0
cedric0715 Messages postés 210 Date d'inscription mercredi 25 février 2015 Statut Membre Dernière intervention 6 mai 2018
13 janv. 2017 à 10:37
j ai fait cela mais sa fonctionne toujours pas
Option Explicit

Private Sub CommandButton1_Click()
Dim NewLig As Long
With Sheets("suivi DI")

NewLig = Range("A65536").End(xlUp).Row + 1



End With
Range("a" & NewLig).Value=Newlig
Range("B" & NewLig).Value = ComboBox1
Range("C" & NewLig).Value = ComboBox2
Range("D" & NewLig).Value = ComboBox3
Range("E" & NewLig).Value = ComboBox4
Range("F" & NewLig).Value = TextBox1
Range("G" & NewLig).Value = ComboBox5
Range("H" & NewLig).Value = TextBox2
Range("I" & NewLig).Value = TextBox3
Unload UserForm1
End Sub
0
cedric0715 Messages postés 210 Date d'inscription mercredi 25 février 2015 Statut Membre Dernière intervention 6 mai 2018
13 janv. 2017 à 10:41
désoler je n'avait pas vu
merci
0