1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Private Sub Worksheet_Change(ByVal Target As Range)
Dim tR As Long
If Target.Column = 6 Then
'MsgBox "target address : " & Target.Address
tR = Target.Row
Select Case Target
Case "CAO"
Range("D" & tR).Formula = "=WORKDAY(" & Range("C" & tR) & "," & Range("B" & tR) & "," & [Fériés] & ""
Case "CAI"
Range("D" & tR) = Range("C" & tR) + Range("B" & tR) - 1
End Select
Range("D" & tR).NumberFormat = "dd/MM/yyyy"
Range("E" & tR).Formula = "=IF(" & Range("D" & tR) & "-TODAY()<0,""""," & Range("D" & tR) & "-TODAY())"
Range("E" & tR).NumberFormat = "dd"
End If
End Sub |