Private Sub CommandButton1_Click()
Dim li As Byte
Dim col As Byte
Dim ai As Double
li = Me.ComboBox1.ListIndex + 7
col = Me.ComboBox2.Column(1, Me.ComboBox2.ListIndex)
With Sheets("Données")
Select Case col
Case 16
ai = .Cells(li, col - 3).Value
Case 20 To 44
ai = .Cells(li, col - 4).Comment.Text
End Select
.Cells(li, col).ClearComments
If CDbl(Me.TextBox1.Value) >= ai Then
.Cells(li, col).AddComment (TextBox1.Value)
.Cells(li, col).Value = CDbl(Me.TextBox1.Value) - ai
Else
MsgBox "Résultat négatif donc refusé !", vbInformation, "Attention"
End If
End With
Me.TextBox1.Value = ""
End Sub