Bonjour je souhaiterais une aide pour cette formule
les deux premières colonnes fonctionnent ex : j'entre 100 en a10 et
j'obtiens 40
ex : j'entre
80 en b10 et j'obtiens 60
mais pas la troisième si j'entre 30 ça reste 30 Pq?
Merci de l'aide
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo FIN
Dim d As Double
If Not Intersect(Target, [A10:A25]) Is Nothing Then d = 5
If Not Intersect(Target, [b10:b25]) Is Nothing Then d = 4
If Not Intersect(Target, [A10:A25]) Is Nothing Then m = 2
If Not Intersect(Target, [b10:b25]) Is Nothing Then m = 3
If Not Intersect(Target, [c10:c25]) Is Nothing Then m = 2
Application.EnableEvents = False
If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = Target / d
If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = Target * m
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Fdecourt
Salut,
C'est normal, cela renvoit une erreur. La division par 0 n'est pas possible. Dans ton troisième cas, m = 2 mais d = 0, donc le premier calcul te renvoit forcément une erreur car Target / 0 n'est pas possible.
Pour que cela fonctionne, il faut que par defaut d soit égal à 1 (j'ai aussi enlevé If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = Target * m)
Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo FIN Dim d As Double d = 1 If Not Intersect(Target, [A10:A25]) Is Nothing Then d = 5 If Not Intersect(Target, [b10:b25]) Is Nothing Then d = 4 If Not Intersect(Target, [A10:A25]) Is Nothing Then m = 2 If Not Intersect(Target, [b10:b25]) Is Nothing Then m = 3 If Not Intersect(Target, [c10:c25]) Is Nothing Then m = 2 Application.EnableEvents = False If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = (Target / d) * m
FIN: Application.EnableEvents = True End Sub
Cordialement,
F.
Salut,
C'est normal, cela renvoit une erreur. La division par 0 n'est pas
possible.
Dans ton troisième cas, m = 2 mais d = 0, donc le premier calcul te
renvoit forcément une erreur car Target / 0 n'est pas possible.
Pour que cela fonctionne, il faut que par defaut d soit égal à 1
(j'ai aussi enlevé If (IsNumeric(Target) And Not IsEmpty(Target)) Then
Target = Target * m)
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo FIN
Dim d As Double
d = 1
If Not Intersect(Target, [A10:A25]) Is Nothing Then d = 5
If Not Intersect(Target, [b10:b25]) Is Nothing Then d = 4
If Not Intersect(Target, [A10:A25]) Is Nothing Then m = 2
If Not Intersect(Target, [b10:b25]) Is Nothing Then m = 3
If Not Intersect(Target, [c10:c25]) Is Nothing Then m = 2
Application.EnableEvents = False
If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = (Target /
d) * m
C'est normal, cela renvoit une erreur. La division par 0 n'est pas possible. Dans ton troisième cas, m = 2 mais d = 0, donc le premier calcul te renvoit forcément une erreur car Target / 0 n'est pas possible.
Pour que cela fonctionne, il faut que par defaut d soit égal à 1 (j'ai aussi enlevé If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = Target * m)
Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo FIN Dim d As Double d = 1 If Not Intersect(Target, [A10:A25]) Is Nothing Then d = 5 If Not Intersect(Target, [b10:b25]) Is Nothing Then d = 4 If Not Intersect(Target, [A10:A25]) Is Nothing Then m = 2 If Not Intersect(Target, [b10:b25]) Is Nothing Then m = 3 If Not Intersect(Target, [c10:c25]) Is Nothing Then m = 2 Application.EnableEvents = False If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = (Target / d) * m
FIN: Application.EnableEvents = True End Sub
Cordialement,
F.
hys56
Bonsoir et merci bcp ça fonctionne correctement cordialement
"Fdecourt" a écrit dans le message de news:
Salut,
C'est normal, cela renvoit une erreur. La division par 0 n'est pas possible. Dans ton troisième cas, m = 2 mais d = 0, donc le premier calcul te renvoit forcément une erreur car Target / 0 n'est pas possible.
Pour que cela fonctionne, il faut que par defaut d soit égal à 1 (j'ai aussi enlevé If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = Target * m)
Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo FIN Dim d As Double d = 1 If Not Intersect(Target, [A10:A25]) Is Nothing Then d = 5 If Not Intersect(Target, [b10:b25]) Is Nothing Then d = 4 If Not Intersect(Target, [A10:A25]) Is Nothing Then m = 2 If Not Intersect(Target, [b10:b25]) Is Nothing Then m = 3 If Not Intersect(Target, [c10:c25]) Is Nothing Then m = 2 Application.EnableEvents = False If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = (Target / d) * m
FIN: Application.EnableEvents = True End Sub
Cordialement,
F.
Bonsoir et merci bcp ça fonctionne correctement
cordialement
"Fdecourt" <fdecourt@gmail.com> a écrit dans le message de news:
2aca5748-43c2-4b4d-ad29-aea7b1f96a21@o20g2000vbh.googlegroups.com...
Salut,
C'est normal, cela renvoit une erreur. La division par 0 n'est pas
possible.
Dans ton troisième cas, m = 2 mais d = 0, donc le premier calcul te
renvoit forcément une erreur car Target / 0 n'est pas possible.
Pour que cela fonctionne, il faut que par defaut d soit égal à 1
(j'ai aussi enlevé If (IsNumeric(Target) And Not IsEmpty(Target)) Then
Target = Target * m)
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo FIN
Dim d As Double
d = 1
If Not Intersect(Target, [A10:A25]) Is Nothing Then d = 5
If Not Intersect(Target, [b10:b25]) Is Nothing Then d = 4
If Not Intersect(Target, [A10:A25]) Is Nothing Then m = 2
If Not Intersect(Target, [b10:b25]) Is Nothing Then m = 3
If Not Intersect(Target, [c10:c25]) Is Nothing Then m = 2
Application.EnableEvents = False
If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = (Target /
d) * m
Bonsoir et merci bcp ça fonctionne correctement cordialement
"Fdecourt" a écrit dans le message de news:
Salut,
C'est normal, cela renvoit une erreur. La division par 0 n'est pas possible. Dans ton troisième cas, m = 2 mais d = 0, donc le premier calcul te renvoit forcément une erreur car Target / 0 n'est pas possible.
Pour que cela fonctionne, il faut que par defaut d soit égal à 1 (j'ai aussi enlevé If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = Target * m)
Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo FIN Dim d As Double d = 1 If Not Intersect(Target, [A10:A25]) Is Nothing Then d = 5 If Not Intersect(Target, [b10:b25]) Is Nothing Then d = 4 If Not Intersect(Target, [A10:A25]) Is Nothing Then m = 2 If Not Intersect(Target, [b10:b25]) Is Nothing Then m = 3 If Not Intersect(Target, [c10:c25]) Is Nothing Then m = 2 Application.EnableEvents = False If (IsNumeric(Target) And Not IsEmpty(Target)) Then Target = (Target / d) * m