OVH Cloud OVH Cloud

Fonction VB ????

8 réponses
Avatar
Wenlok
Bonjour,

Comment puis-je tranformer cette forumule
=SI(C11>E11;(C11-E11)/2;0)

en fonction VB du style:

Function SommeCompte
.
.
.
.
.
End Function


Merci

8 réponses

Avatar
Nicolas B.
Salut,

Function SommeCompte(c1 As Double, c2 As Double)
SommeCompte = Evaluate("IF(" & c1 & ">" & c2 & ",(" & c1 _
& "-" & c2 & ")/2,0)")
End Function

ou encore :

Function SommeCompte(c1 As Double, c2 As Double)
If c1 > c2 Then
SommeCompte = (c1 - c2) / 2
Else
SommeCompte = 0
End If
End Function


A+
Nicolas B.

Bonjour,

Comment puis-je tranformer cette forumule
=SI(C11>E11;(C11-E11)/2;0)

en fonction VB du style:

Function SommeCompte
..
..
..
..
..
End Function


Merci





Avatar
JB
Bonjour,

Function SommeCompte(x, y)
If x > y Then
SommeCompte = (x - y) / 2
Else
SommeCompte = 0
End If
End Function

Dans le tableur: =SommeCompte(C11;E11)

Cordialement JB


Bonjour,

Comment puis-je tranformer cette forumule
=SI(C11>E11;(C11-E11)/2;0)

en fonction VB du style:

Function SommeCompte
.
.
.
.
.
End Function


Merci


Avatar
JB
Function SommeCompte(x, y)
SommeCompte = IIf(x > y, (x - y) / 2, 0)
End Function

JB

Bonjour,

Comment puis-je tranformer cette forumule
=SI(C11>E11;(C11-E11)/2;0)

en fonction VB du style:

Function SommeCompte
.
.
.
.
.
End Function


Merci


Avatar
Wenlok
Merci


"Wenlok" a écrit dans le message de news:
44d31c73$0$880$
Bonjour,

Comment puis-je tranformer cette forumule
=SI(C11>E11;(C11-E11)/2;0)

en fonction VB du style:

Function SommeCompte
.
.
.
.
.
End Function


Merci





Avatar
Wenlok
Que signifie As Double

"Nicolas B." a écrit dans le message
de news: OBno6$
Salut,

Function SommeCompte(c1 As Double, c2 As Double)
SommeCompte = Evaluate("IF(" & c1 & ">" & c2 & ",(" & c1 _
& "-" & c2 & ")/2,0)")
End Function

ou encore :

Function SommeCompte(c1 As Double, c2 As Double)
If c1 > c2 Then
SommeCompte = (c1 - c2) / 2
Else
SommeCompte = 0
End If
End Function


A+
Nicolas B.

Bonjour,

Comment puis-je tranformer cette forumule
=SI(C11>E11;(C11-E11)/2;0)

en fonction VB du style:

Function SommeCompte
..
..
..
..
..
End Function


Merci






Avatar
ABED HADDOU
Bonjour,
Pardonne moi Wenlok
Ps: Monsieur JB , si le TypeName( x, y) = Range ou x ou y
comment écrire la fonction ?

Merci beaucopup

Abed_H




Function SommeCompte(x, y)
SommeCompte = IIf(x > y, (x - y) / 2, 0)
End Function

JB

Bonjour,

Comment puis-je tranformer cette forumule
=SI(C11>E11;(C11-E11)/2;0)

en fonction VB du style:

Function SommeCompte
.
.
.
.
.
End Function


Merci






Avatar
Nicolas B.
c1 as Double : signifie que tu définis une variable c1 qui est du type
double, c'est-à-dire un nombre à virgule flottante avec à peu près 15
chiffres significatifs.

Regarde l'aide VBA sur le type double pour en savoir plus.


Nicolas B.

Que signifie As Double

"Nicolas B." a écrit dans le message
de news: OBno6$
Salut,

Function SommeCompte(c1 As Double, c2 As Double)
SommeCompte = Evaluate("IF(" & c1 & ">" & c2 & ",(" & c1 _
& "-" & c2 & ")/2,0)")
End Function

ou encore :

Function SommeCompte(c1 As Double, c2 As Double)
If c1 > c2 Then
SommeCompte = (c1 - c2) / 2
Else
SommeCompte = 0
End If
End Function


A+
Nicolas B.

Bonjour,

Comment puis-je tranformer cette forumule
=SI(C11>E11;(C11-E11)/2;0)

en fonction VB du style:

Function SommeCompte
..
..
..
..
..
End Function


Merci









Avatar
ABED HADDOU
Ouuups....... je n'ai pas vérifier! donc c'est bon éxcuse moi Monsieur JB
merci

Abed_H



Bonjour,
Pardonne moi Wenlok
Ps: Monsieur JB , si le TypeName( x, y) = Range ou x ou y
comment écrire la fonction ?

Merci beaucopup

Abed_H




Function SommeCompte(x, y)
SommeCompte = IIf(x > y, (x - y) / 2, 0)
End Function

JB

Bonjour,

Comment puis-je tranformer cette forumule
=SI(C11>E11;(C11-E11)/2;0)

en fonction VB du style:

Function SommeCompte
.
.
.
.
.
End Function


Merci