1 pièce(s) jointe(s)
définir variable - un chiffre après la virgule
Bonjour,
J'ai un problème avec ma macro,
Ce code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| Private Sub Worksheet_ChangementB2(ByVal Target As Range)
Dim KeyCells As Range
Dim resultat As Single
Set KeyCells = Range("B2")
If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
If Range("B1").Value <> "" Then
If Range("B2").Value < Range("B1").Value - Range("B3").Value And Range("B2").Value <= 10 Then
resultat = Range("B1").Value - Range("B2").Value - Range("B3").Value
MsgBox ("il vous reste " & resultat & " jours")
End If
End If
End If
End Sub
Private Sub Worksheet_ChangementB3(ByVal Target As Range)
Dim KeyCells As Range
Dim resultat As Single
Set KeyCells = Range("B3")
If Not Application.Intersect(KeyCells, Range(Target.Address)) Is Nothing Then
If Range("B1").Value <> "" Then
If Range("B3").Value < Range("B1").Value - Range("B2").Value And Range("B3").Value <= 10 Then
resultat = Range("B1").Value - Range("B2").Value - Range("B3").Value
MsgBox ("il vous reste " & resultat & " jours")
End If
End If
End If
End Sub |
devrait me permettre de générer un msg box pour me calculer l'écart de saisie (cf résultat dans le code)
sauf que dans l'exemple que je vous donne, j'ai bien saisi dans ma B2 et B3 des valeurs correspondant au cumul de ma B1, donc je ne devrai pas avoir de msg box
là j'ai un écart bizarre qui sort et je ne sais pas à quoi ca correspond
est ce que c'est un problème du format de la variable?
ou je dois définir les décimales de mon résultat?
merci de votre aide