Bonjour
Afin de me déplacer sur la ligne suivante de haut en bas j'ai copié et amélioré le code suivant :
---------------------------------------------------------------------------------------------
Private Sub CommandButton4_Click()
'Bouton ligne suivante dans la liste déroulante
'MsgBox ("Aller dans l'onglet ""Materiels"" à la ligne suivante")
If ActiveWorkbook.Name <> ThisWorkbook.Name Then ThisWorkbook.Activate
Sheets("Materiels").Select
If Me.ComboBox1.ListIndex > -1 Then
Me.ComboBox1.ListIndex = Me.ComboBox1.ListIndex + 1
[B2].Offset(Me.ComboBox1.ListIndex, 0).Select
End If
End Sub
-------------------------------------------------------------------------------------------
Je rencontre la difficulté suivante :
Lorsque la ligne suivante est vide, mon code BUG et j'aperçois le message suivant :
"Erreur d’exécution 380" Debug
Pouvez-vous m'aider à rajouter une condition : Si la ligne est vide je reste sur la dernière ligne renseignée.
--> If Me.ComboBox1.ListIndex = 0 Then......
Private Sub CommandButton4_Click()
ThisWorkbook.Sheets("Materiels").Activate
With ComboBox1
If .ListIndex = -1 Then Exit Sub
If .ListIndex < .ListCount - 1 Then .ListIndex = .ListIndex + 1
[B2].Offset(.ListIndex).Select
End With
End Sub
Private Sub CommandButton4_Click()
ThisWorkbook.Sheets("Materiels").Activate
With ComboBox1
If .ListIndex = -1 Then Exit Sub
If .ListIndex < .ListCount - 1 Then .ListIndex = .ListIndex + 1
[B2].Offset(.ListIndex).Select
End With
End Sub
Bonjour
Effectivement votre code est plus explicite et mieux adapté à ma demande.
J'ai copié collé votre code en remplacement de mon ancien code et cela fonctionne très bien
Merci à vous
Bonne journée