Option Explicit
Private Sub CommandButton2_Click()
Dim lig&, i&, x As ListObject, aux, y As ListRow
Application.ScreenUpdating = True
If Trim(TextBox13) = "" Then MsgBox "Type de dépense absent => Échec!", vbCritical: Exit Sub
For i = 1 To 12: aux = aux & Trim(Controls("textbox" & i)): Next
If aux = "" Then MsgBox "Aucune valeur mensuelle => Échec!", vbCritical: Exit Sub
With Range("a1").ListObject
.ListRows.Add
Set y = .ListRows(.ListRows.Count)
With y
.Range(1, 1) = TextBox13
.Range(1, 2) = Val(Replace(TextBox14, ",", "."))
For i = 1 To 12: .Range(1, i + 2) = Val(Replace(Controls("textbox" & i), ",", ".")): Next
End With
End With
For i = 1 To 14: Controls("textbox" & i) = "": Next
End Sub
Sub Somme()
Dim i&, x
For i = 1 To 12: x = x + Val(Replace(Controls("textbox" & i), ",", ".")): Next
TextBox14 = x
End Sub
Private Sub TextBox1_Change(): Somme: End Sub
Private Sub TextBox2_Change(): Somme: End Sub
Private Sub TextBox3_Change(): Somme: End Sub
Private Sub TextBox4_Change(): Somme: End Sub
Private Sub TextBox5_Change(): Somme: End Sub
Private Sub TextBox6_Change(): Somme: End Sub
Private Sub TextBox7_Change(): Somme: End Sub
Private Sub TextBox8_Change(): Somme: End Sub
Private Sub TextBox9_Change(): Somme: End Sub
Private Sub TextBox10_Change(): Somme: End Sub
Private Sub TextBox11_Change(): Somme: End Sub
Private Sub TextBox12_Change(): Somme: End Sub