Bonsoir,
C'est ce que j'ai fait dans
Sub Total_Click()
Dim i
moShCD.Unprotect
'Calcul du total
txtTotal.Text = 0
txtTotal.Text = Round(txtTotal.Text, 2)
'MsgBox (Total)
Worksheets("Crédit_Débit").Select
Cells(10, 26) = frmAjouter_Ventiller.txtMontant1.Text
Cells(11, 26) = frmAjouter_Ventiller.txtMontant2.Text
Cells(12, 26) = frmAjouter_Ventiller.txtMontant3.Text
Cells(13, 26) = frmAjouter_Ventiller.txtMontant4.Text
Cells(14, 26) = frmAjouter_Ventiller.txtMontant5.Text
Cells(15, 26) = frmAjouter_Ventiller.txtMontant6.Text
Cells(16, 26) = Cells(10, 26) + Cells(11, 26) + Cells(12, 26) + Cells(13, 26) + Cells(14, 26) + Cells(15, 26)
Cells(17, 26) = frmAjouter_Ventiller.textMontant0.Text
frmAjouter_Ventiller.txtTotal = Round(Cells(16, 26), 2)
Cells(16, 26) = Round(Cells(16, 26), 2)
If frmAjouter_Ventiller.textMontant0.Text <> Round(frmAjouter_Ventiller.txtTotal, 2) Then
MsgBox ("Vérifier que la somme des valeurs est égale du montant à ventiler"), i = 0
frmAjouter_Ventiller.cmdOK.Enabled = True
Call SaisieOK
End If
If frmAjouter_Ventiller.textMontant0.Text = frmAjouter_Ventiller.txtTotal Then
frmAjouter_Ventiller.cmdOK.Enabled = True
Call SaisieOK
End If
For i = 10 To 17
Cells(i, 26) = ""
Next
End Sub
LA comparaison se fait ici :
If frmAjouter_Ventiller.textMontant0.Text <> Round(frmAjouter_Ventiller.txtTotal, 2) Then
MsgBox ("Vérifier que la somme des valeurs est égale du montant à ventiler"), i = 0
frmAjouter_Ventiller.cmdOK.Enabled = True
Call SaisieOK
End If
If frmAjouter_Ventiller.textMontant0.Text = frmAjouter_Ventiller.txtTotal Then
frmAjouter_Ventiller.cmdOK.Enabled = True
Call SaisieOK
End If
Les valeurs de If frmAjouter_Ventiller.textMontant0.Text sont écrites manuellement (donc pas calculé), toujours avec le dixième.
C'est la valeurs "frmAjouter_Ventiller.txtTotal" qui est calculé avec
Sub Check_Data()
Dim Ct As Integer
Dim Sqdata1(6) As String
Dim All, Zz As Integer
'Calcul du total
txtTotal = 0
txtTotal = txtMontantl + txtMontant2 + txtMontant3 + txtMontant4 + txtMontant5 + txtMontant6
End Sub
Et si je met if Round(frmAjouter_Ventiller.textMontant0.Text,2) <> Round(frmAjouter_Ventiller.txtTotal, 2) then avec ou sans "Cells(17, 26) = Round(frmAjouter_Ventiller.textMontant0.Text, 2), la macro m'indiquer "incompatibilité de type".