britchouleloup
XLDnaute Junior
Bonjour,
Voici ma démarche :
1- saisie dans une textbox d'un montant décimal ou non, j'ai associé à ce textbox trois procédures :
additionner les textbox dans un autre textbox en "direct" et afficher le total dedans
Private Sub mttrec1_Change()
totmttrec = Format(calc, "# ##0.00")
End Sub
beforeupadate : vérifier qu'il s'agit d'un nombre
Private Sub mttrec1_beforeupdate(ByVal cancel As MSForms.ReturnBoolean)
If IsNumeric(mttrec1) = False Then
MsgBox "Merci de saisir un montant valide !"
cancel = True
End If
End Sub
afterupdate : AFFICHER 2 chiffres après virgule même si entier
Private Sub mttrec1_AfterUpdate()
mttrec1.Value = Format(mttrec1.Value, "00.00")
End Sub
2- La validation de l'userform balance le montant des textbox dans des cellules au format comptabilité comme suit :
If mttrec1 <> Empty Then
Range("d" & ligne) = CDbl(mttrec1)
End If
PROBLEME
Le total textbox se fait parfaitement si je mets un point pour séparer décimale mais je peux pas changer de textbox du fait de mon beforeupdate. Par contre si je mets une virgule, il me fait plus l'addition des décimales correctement, mais me valide mon beforeupdate.
Comment faire???
Je suis un peu perdu, pourriez vous m'aider.
Merci par avance.
Voici ma démarche :
1- saisie dans une textbox d'un montant décimal ou non, j'ai associé à ce textbox trois procédures :
additionner les textbox dans un autre textbox en "direct" et afficher le total dedans
Private Sub mttrec1_Change()
totmttrec = Format(calc, "# ##0.00")
End Sub
beforeupadate : vérifier qu'il s'agit d'un nombre
Private Sub mttrec1_beforeupdate(ByVal cancel As MSForms.ReturnBoolean)
If IsNumeric(mttrec1) = False Then
MsgBox "Merci de saisir un montant valide !"
cancel = True
End If
End Sub
afterupdate : AFFICHER 2 chiffres après virgule même si entier
Private Sub mttrec1_AfterUpdate()
mttrec1.Value = Format(mttrec1.Value, "00.00")
End Sub
2- La validation de l'userform balance le montant des textbox dans des cellules au format comptabilité comme suit :
If mttrec1 <> Empty Then
Range("d" & ligne) = CDbl(mttrec1)
End If
PROBLEME
Le total textbox se fait parfaitement si je mets un point pour séparer décimale mais je peux pas changer de textbox du fait de mon beforeupdate. Par contre si je mets une virgule, il me fait plus l'addition des décimales correctement, mais me valide mon beforeupdate.
Comment faire???
Je suis un peu perdu, pourriez vous m'aider.
Merci par avance.