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
| Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
ActiveSheet.Unprotect ("...")
[S]Cancel = True
'Colonne A : si avant 7:30 on met 7:30
If Target.Column = 1 Then
If Time < TimeSerial(7, 30, 0) Then
Target.Value = TimeSerial(7, 30, 0)
Else
Target.Value = Time
End If
Else
'Colonne B : si après 12:00 on met 12:00
If Target.Column = 2 Then
If Time > TimeSerial(12, 0, 0) Then
Target.Value = TimeSerial(12, 0, 0)
Else
Target.Value = Time
End If
Else
'Colonne C : si avant 13:30 on met 13:30
If Target.Column = 3 Then
If Time < TimeSerial(13, 30, 0) Then
Target.Value = TimeSerial(13, 30, 0)
Else
Target.Value = Time
End If
Else
'Colonne D : si après 18:00 on met 18:00
If Target.Column = 4 Then
If Time > TimeSerial(18, 0, 0) Then
Target.Value = TimeSerial(18, 0, 0)
Else
Target.Value = Time
End If
'Autres colonnes
Else
Target.Value = Time
End If
End If
Target.Interior.ColorIndex = 34
Target.Locked = True
ActiveSheet.Protect ("...")
For Each w In Application.Workbooks
w.Save
Next w
Application.CommandBars("Ply").Enabled = True
Application.Quit
End Sub |
Partager