Function Jour_Ouvré()
lig = Application.ThisCell.Row - 1 ' à adapter
Rec = Range("DateReception")(lig)
Rep = Range("DateReparation")(lig)
If Range("test")(lig) = "oui" Then
Jour_Ouvré = Evaluate("NB.JOURS.OUVRES(""" & Rec & """,""" & Rep & """,JOURSFERIES")
Else
Jour_Ouvré = ""
End If
End Function
Function Jour_Ouvré_V2(Position As Range)
Application.Volatile
lig = Position.Row
Rec = Range("DateReception")(lig)
Rep = Range("DateReparation")(lig)
If Range("test")(lig) = "oui" Then
Jour_Ouvré_V2 = Evaluate("NB.JOURS.OUVRES(""" & Rec & """,""" & Rep & """,JOURSFERIES")
Else
Jour_Ouvré_V2 = ""
End If
End Function
Sub calcul()
Dim RngTest As Range, cel As Range, c1 As Byte, c2 As Byte, c3 As Byte
c1 = Feuil1.Rows(1).Find("Date de reception", LookIn:=xlValues, lookat:=xlWhole).Column
c2 = Feuil1.Rows(1).Find("Date de reparation", LookIn:=xlValues, lookat:=xlWhole).Column
c3 = Feuil1.Rows(1).Find("test", LookIn:=xlValues, lookat:=xlWhole).Column
Set RngTest = Feuil1.Range(Feuil1.Cells(2, c3), Feuil1.Cells(5, c3))
For Each cel In RngTest
Feuil1.Cells(cel.Row, c3 + 1).FormulaLocal = "=si(" & cel.Address(0, 0) & "=" & """Oui""" & ";NB.Jours.ouvres(" & Cells(cel.Row, c1).Address(0, 0) & ";" & Cells(cel.Row, c2).Address(0, 0) & ";Ref!A2:A6);0)"
Next
End Sub
Function Jour_Ouvré_V2(Position As Range)
Dim Lig As Long, Rec As Date, Rep As Date, x As String, y As String ', z As String
Application.Volatile
Lig = Position.Row
x = "A" & Lig: y = "B" & Lig
'Rec = Range("DateReception")(Lig) 'CDate(Format(, "dd/mm/yyyy"))
'Rep = Range("DateReparation")(Lig) 'CDate(Format(, "dd/mm/yyyy"))
'z = "NB.JOURS.OUVRES(" & x & ";" & y & ";JOURSFERIES"
If Range("test")(Lig) = "oui" Then
' Jour_Ouvré_V2 = Evaluate("NB.JOURS.OUVRES(" & x & ";" & y & ";JOURSFERIES") 'NB.JOURS.OUVRES
Jour_Ouvré_V2 = Evaluate("NETWORKDAYS(" & x & "," & y & ",JOURSFERIES") 'NB.JOURS.OUVRES
' Jour_Ouvré_V2 = Evaluate("NETWORKDAYS(""" & Rec & """,""" & Rep & """,JOURSFERIES") 'NB.JOURS.OUVRES
Else
Jour_Ouvré_V2 = ""
End If
End Function
Function Jour_Ouvré_V3(Position As Range)
Dim Lig As Long, Rec As String, Rep As String
Application.Volatile
Lig = Position.Row
Rec = Range("DateReception")(Lig).Address
Rep = Range("DateReparation")(Lig).Address
If Range("test")(Lig) = "oui" Then
' Jour_Ouvré_V2 = Evaluate("NB.JOURS.OUVRES(" & Rec & "," & Rep & ",JOURSFERIES")
Jour_Ouvré_V3 = Evaluate("NETWORKDAYS(" & Rec & "," & Rep & ",JOURSFERIES") 'NB.JOURS.OUVRES
Else
Jour_Ouvré_V3 = ""
End If
End Function