OVH Cloud OVH Cloud

heure X tarif dans une variable

2 réponses
Avatar
fetnat
Bonjour,
Je cherche comment multiplier une variable au format date hh:mm par une
variable integer qui represente des euros.

Dans la feuille, pas de problème.
U2 contient 1:30
U2*100 = 150

Dans le VBA, je somme B3+C3+D3 dans une var
Set plg = Range(Cells(n, coldebsource), Cells(n, coldebsource + 2))
x1 = Application.Sum(plg)
et j'ai bien 01:30:00
j'ai le tarif dans une variable tarif1 = 100


Mais la multiplication honoraireclimois ne donne pas le bon résultat.
J'ai 6 comme résultat.


Sub tarif()
'somme B3+C3+D3
Dim coldebsource As Integer, honoraireclimois As Integer
Dim x1 As Date, n As Integer, fmois As Integer
Dim plg As Range

Const tarif1 = 100
n = 3
coldebsource = 2
fmois = 20
honoraireclimois = 0
x1 = 0
Set plg = Range(Cells(n, coldebsource), Cells(n, coldebsource + 2))
If ThisWorkbook.Worksheets(fmois).Cells(n, 10) <> "0:00" Then
x1 = Application.Sum(plg)
honoraireclimois = x1 * tarif1
Worksheets(fmois).Select
End If
End Sub

Merci d'avance

Fetnat

2 réponses

Avatar
Daniel
Bonsoir.
Une heure égale 1/24. Si tu multiplies 1h30 par cent, tu obtiens 6,25 jours.
Positionne ta variable honoraireclimois comme étant de type Long et
multiplie par 24 pour obtenir ton résultat :
honoraireclimois = x1 * tarif1 * 24
Cordialement.
Daniel
"fetnat" a écrit dans le message de news:

Bonjour,
Je cherche comment multiplier une variable au format date hh:mm par une
variable integer qui represente des euros.

Dans la feuille, pas de problème.
U2 contient 1:30
U2*100 = 150

Dans le VBA, je somme B3+C3+D3 dans une var
Set plg = Range(Cells(n, coldebsource), Cells(n, coldebsource + 2))
x1 = Application.Sum(plg)
et j'ai bien 01:30:00
j'ai le tarif dans une variable tarif1 = 100


Mais la multiplication honoraireclimois ne donne pas le bon résultat.
J'ai 6 comme résultat.


Sub tarif()
'somme B3+C3+D3
Dim coldebsource As Integer, honoraireclimois As Integer
Dim x1 As Date, n As Integer, fmois As Integer
Dim plg As Range

Const tarif1 = 100
n = 3
coldebsource = 2
fmois = 20
honoraireclimois = 0
x1 = 0
Set plg = Range(Cells(n, coldebsource), Cells(n, coldebsource + 2))
If ThisWorkbook.Worksheets(fmois).Cells(n, 10) <> "0:00" Then
x1 = Application.Sum(plg)
honoraireclimois = x1 * tarif1
Worksheets(fmois).Select
End If
End Sub

Merci d'avance

Fetnat


Avatar
fetnat
Bonjour,

C'est parfait, merci beaucoup pour votre aide Monsieur.

Fetnat

Bonsoir.
Une heure égale 1/24. Si tu multiplies 1h30 par cent, tu obtiens 6,25 jours.
Positionne ta variable honoraireclimois comme étant de type Long et
multiplie par 24 pour obtenir ton résultat :
honoraireclimois = x1 * tarif1 * 24
Cordialement.
Daniel
"fetnat" a écrit dans le message de news:


Bonjour,
Je cherche comment multiplier une variable au format date hh:mm par une
variable integer qui represente des euros.

Dans la feuille, pas de problème.
U2 contient 1:30
U2*100 = 150

Dans le VBA, je somme B3+C3+D3 dans une var
Set plg = Range(Cells(n, coldebsource), Cells(n, coldebsource + 2))
x1 = Application.Sum(plg)
et j'ai bien 01:30:00
j'ai le tarif dans une variable tarif1 = 100


Mais la multiplication honoraireclimois ne donne pas le bon résultat.
J'ai 6 comme résultat.


Sub tarif()
'somme B3+C3+D3
Dim coldebsource As Integer, honoraireclimois As Integer
Dim x1 As Date, n As Integer, fmois As Integer
Dim plg As Range

Const tarif1 = 100
n = 3
coldebsource = 2
fmois = 20
honoraireclimois = 0
x1 = 0
Set plg = Range(Cells(n, coldebsource), Cells(n, coldebsource + 2))
If ThisWorkbook.Worksheets(fmois).Cells(n, 10) <> "0:00" Then
x1 = Application.Sum(plg)
honoraireclimois = x1 * tarif1
Worksheets(fmois).Select
End If
End Sub

Merci d'avance

Fetnat