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
| Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
ActiveSheet.Unprotect ("0000")
Cancel = True
'Colonne D : si avant 8:00 on met 8:00
If Target.Column = 4 Then
If Time < TimeSerial(8, 0, 0) Then
Target.Value = TimeSerial(8, 0, 0)
Else
Target.Value = Time
End If
Else
'Colonne E : si avant 12:00 on met time, si entre 12:00 et 12:15 on met 12:00, si après 12:15 on met 12:15
If Target.Column = 5 Then
Application.EnableEvents = False
If Time > TimeSerial(12, 15, 0) Then
Target.Value = TimeSerial(12, 15, 0)
ElseIf Time > TimeSerial(12, 0, 0) Then
Target.Value = TimeSerial(12, 0, 0)
Else
Target.Value = Time
Application.EnableEvents = True
End If
Else
'Colonne F : si avant 14:00 on met 14:00
If Target.Column = 6 Then
If Time < TimeSerial(14, 0, 0) Then
Target.Value = TimeSerial(14, 0, 0)
Else
Target.Value = Time
End If
Else
'Colonne G : si après 17:00 on met 17:00
If Target.Column = 7 Then
If Time > TimeSerial(17, 0, 0) Then
Target.Value = TimeSerial(17, 0, 0)
Else
Target.Value = Time
End If
End If
End If
End If
End If
Target.Value = Time
Target.Interior.ColorIndex = 34
Target.Locked = True
ActiveSheet.Protect ("0000")
For Each w In Application.Workbooks
w.Save
Next w
Application.CommandBars("Ply").Enabled = True
Application.Quit
End Sub |