Bonjour le Forum,
Bonjour laceline,
j'ai trouvé une portion du code pour forcer l'inscription d'une cellule, mais il est incomplet!
J'aimerais que le message pour la colonne H et l'exécution de la commande (l'obligation de compléter si la cellule n'est pas remplir) puisse se faire avant l'ouverture de l'userform Comblement.
Les utilisateurs du classeur utilisent le tabulateur pour passer d'une cellule à l'autre.
Merci pour votre aide, et toute proposition pour améliorer ce code.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
adresse = Target.Address
For I = 5 To 65536
If adresse = "$A$" & I Then
Calendrier.Show
Cancel = True
Exit For
End If
Next
If Target.Count < 2 And Target.Column = 1 Then
Cells(Target.Row, 1).Copy Destination:=Cells(Target.Row, 2)
Cells(Target.Row, 2).NumberFormat = "dddd"
Target.Offset(0, 2).Select
End If
'If Target.Count > 1 Then Exit Sub
'If Not Application.Intersect(Target, Range("F5:F" & Range("B" & Rows.Count).End(xlUp).Row)) Is Nothing Then
'MsgBox ("Pour un quart de travail sans repas, inscrivez 0000.")
'End If
'If Target.Count > 1 Then Exit Sub
'If Not Application.Intersect(Target, Range("H5:H" & Range("B" & Rows.Count).End(xlUp).Row)) Is Nothing Then
'MsgBox ("Incrivez vos initiales avant de poursuivre.")
'End If
'Code pour forcer; emprunté à DAN
If Target.Count > 1 Then Exit Sub
If Application.Intersect(Target, Range("F" & Range("F65536").End(xlUp).Row)) Is Nothing Then
If IsEmpty(Target.Offset(0, -1)) Then
MsgBox "Pour un quart de travail sans repas, inscrivez 0000." & Target.Offset(0, -1).Address
Target.Offset(0, -1).Select
Exit Sub
End If
End If
If Target.Count > 1 Then Exit Sub
If Application.Intersect(Target, Range("H" & Range("H65536").End(xlUp).Row)) Is Nothing Then
If IsEmpty(Target.Offset(0, -1)) Then
MsgBox "Incrivez vos initiales avant de poursuivre." & Target.Offset(0, -1).Address
Target.Offset(0, -1).Select
Exit Sub
End If
End If
If Target.Count > 1 Then Exit Sub
If Not Application.Intersect(Target, Range("H5:H" & Range("B" & Rows.Count).End(xlUp).Row)) Is Nothing Then
Comblement.Show
End If
If Target.Count > 1 Then Exit Sub
If Not Application.Intersect(Target, Range("I5:I" & Range("B" & Rows.Count).End(xlUp).Row)) Is Nothing Then
Traitement.Show
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Heure As String
If Target.Count > 1 Then Exit Sub
If Not Intersect(Range("D5:F65000"), Target) Is Nothing Then
If Not IsNumeric(Target) Then
Target.Select
MsgBox "Seulement des nombres"
Exit Sub
End If
Heure = Format(Abs(Target), "0000")
If Val(Left(Heure, 2)) > 23 Then
Target.Select
MsgBox "Heures non valables"
ElseIf Val(Right(Heure, 2)) > 59 Then
Target.Select
MsgBox "Minutes non valables"
Else
Application.EnableEvents = False
Target = Left(Heure, 2) & ":" & Right(Heure, 2)
Application.EnableEvents = True
If Target.Column = 4 Or Target.Column = 5 Then
Target.Offset(0, 1).Select
ElseIf Target.Column = 6 Then
'Target.Offset(1, -2).Select
End If
End If
End If
End Sub