Private Sub CommandButton4_Click()
Dim j As Double
Dim i As Double
j = Me.TextBox3.Value
i = Me.TextBox2.Value
If IsNumeric(TextBox2) Then MsgBox CDbl(TextBox2)
If IsNumeric(TextBox3) Then MsgBox CDbl(TextBox3)
Sheets("Feuil1").Cells(Me.ComboBox1.ListIndex + 2, Me.ComboBox2.ListIndex + 3) = Me.TextBox2.Value
If i >= j Then
If Worksheets("Feuil1").Range("A" & Me.ComboBox1.ListIndex + 2).Value = "" Then
Sheets("Feuil1").Cells(Me.ComboBox1.ListIndex + 2, Me.ComboBox2.ListIndex + 3) = Me.TextBox2.Value
MsgBox "Vous êtes sur la dernière ligne", vbExclamation, "Message système"
'Et on sort de la procédure
Exit Sub
Else
'Sinon, on incrémente pour descendre d'une ligne
Me.ComboBox1.ListIndex = Me.ComboBox1.ListIndex + 1
'On affiche les données
End If
Else
MsgBox ("la consommation saisie est inférieur à celle du mois précédent "), vbCritical + vbOKOnly, "erreur"
End If