Bonjour à Tous,

j'ai un petit soucis au niveau d'une fonction qui calcule un engagement de Date.

NB: je n'ai pas de message d'erreur

d'après mon analyse la disposition des "IF" dans mon code pose problème. je m'explique :

le résultat ne traite que la première "IF" et condamne la suite. Merci de m'aider svp car c'est un point bloquant pour l'avancement.

Merci d'avance

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Function Engagement(expression) As Date
Dim liberation, EngagementBrute, FINSHIFTS, FINSHIFTSD, ShiftDim As Date
Dim JourDemande, ResteDim As Integer
Dim Ecart, EcartSD As Double
 
 
 
liberation = expression
JourDemande = Weekday(liberation, vbMonday)
 
FINSHIFTS = liberation + (1) - (1 / 24)
 
 
 
EngagementBrute = liberation + 6 / 24
 
 
 
Ecart = FINSHIFTS - EngagementBrute
 
If JourDemande = 6 Then
 
FINSHIFTSD = (Int(liberation) + 1) - (11 / 24)
EcartSD = FINSHIFTSD - EngagementBrute
 
    If EcartSD >= 0 Then
 
    Engagement = EngagementBrute
 
    Else
 
    If EcartSD < 0 Then
 
    Engagement = EngagementBrute + (11 / 24) + (24 / 24) + (6 / 24)
 
    End If
    End If
 
If JourDemande = 7 Then
 
ShiftDim = Int(liberation) + 1
ResteDim = ShiftDim - Now()
 
Engagement = liberation + (ResteDim / 24) + (6 / 24) + (6 / 24)
 
If JourDemande >= 1 And JourDemande <= 5 Then
 
If Ecart >= 0 Then
 
Engagement = EngagementBrute
 
Else
 
If Ecart < 0 Then
 
Engagement = EngagementBrute + 7 / 24
End If
End If
 
 
 
 
End If
End If
End If
End Function