Modification code
t
Bonjour
alors je venais de poster une demande pour mettre a jour un tableau a partir de 2 listbox
en fouillant j'ai trouvé
maintenant je voudrais savoir si ce code peut être optimisé
sachant que lors de la saisie d'info la cellule de la colonne 10 et 11 de la ligne 1000 se remplissent et après lors de la validation ces valeurs viennent modifier les valeurs présente dans le tableau
Private Sub boutton_suivi_maj_Click()
If txt_date_maj.Value = "" Or txt_km_maj.Value = "" Then Exit Sub
If lstcamion.ListIndex <> -1 Then
modif = lstcamion.ListIndex + 2
Sheets("camions").Select
Cells(modif, 10) = Cells(1000, 11)
Cells(modif, 23) = Cells(1000, 10)
ElseIf lstvoiture.ListIndex <> -1 Then
modif = lstvoiture.ListIndex + 2
Sheets("voitures").Select
Cells(modif, 10) = Cells(1000, 11)
Cells(modif, 23) = Cells(1000, 10)
End If
Sheets("voitures").Range("J1000:K1000") = ""
Sheets("camions").Range("J1000:K1000") = ""
End Submerci
t
le code a un peu évolué
doit ton faire une boucle pour optimiser ou cela est il bon?
et comment faire pour avoir,après le unload me, le listindex sur la ligne suivante?
Private Sub boutton_suivi_maj_Click()
If txt_date_maj.Value = "" Or txt_km_maj.Value = "" Then
MsgBox "Veuillez saisir une date et un KM", vbInformation, "Champs manquants"
Exit Sub
ElseIf lstcamion.ListIndex <> -1 Then
modif = lstcamion.ListIndex + 2
Sheets("camions").Select
Cells(modif, 10) = Cells(1000, 11)
Cells(modif, 23) = Cells(1000, 10)
Sheets("camions").Range("J1000:K1000") = ""
txt_date_maj.Value = ""
txt_km_maj.Value = ""
Unload Me
UserForm1.Show
ElseIf lstvoiture.ListIndex <> -1 Then
modif = lstvoiture.ListIndex + 2
Sheets("voitures").Select
Cells(modif, 10) = Cells(1000, 11)
Cells(modif, 23) = Cells(1000, 10)
Sheets("voitures").Range("J1000:K1000") = ""
txt_date_maj.Value = ""
txt_km_maj.Value = ""
Unload Me
UserForm1.Show
End IfEnd Sub
merci