Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Fin: If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, [G4:G1000]) Is Nothing Then
Ligne = Target.Row
If Cells(Ligne, "F") <> "" And Target <> "" Then Cells(Ligne, "H") = "Ok"
End If
Fin:
End Sub
C'est ce que fait ma PJ. Si il n'y a pas de date en G, je ne touche rien, votre formule en H reste intacte.Serait -il possible si la commande est livré en G mettre alors "ok" en H et si possible en vba, je vous remercie
Private Sub Workbook_Open()
With Feuil1
Application.ScreenUpdating = False
.[H4:H1000].Clear
For L = 4 To .[F65500].End(xlUp).Row
If .Cells(L, "F") <> "" And .Cells(L, "G") <> "" Then
.Cells(L, "H") = "Ok"
ElseIf .Cells(L, "F") < Date And .Cells(L, "G") = "" Then
.Cells(L, "H") = "Relance"
.Cells(L, "H").Font.Color = vbRed
.Cells(L, "H").Font.Bold = True
ElseIf .Cells(L, "F") > Date And .Cells(L, "G") = "" Then
' Calcul du temps avant relance, à supprimer si non necessaire.
.Cells(L, "H") = "Relance dans " & .Cells(L, "F") - Date & " jours."
.Cells(L, "H").Font.Italic = True
End If
Next L
End With
End Sub
Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Fin: If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, [G4:G1000]) Is Nothing Then
Ligne = Target.Row
If Cells(Ligne, "F") <> "" And Target <> "" Then
Cells(Ligne, "H") = "Ok"
Cells(Ligne, "H").Font.Color = vbBlack
Cells(Ligne, "H").Font.Bold = False
ElseIf Cells(Ligne, "F") <> "" And Target = "" Then
Cells(Ligne, "H") = "Relance"
Cells(Ligne, "H").Font.Color = vbRed
Cells(Ligne, "H").Font.Bold = True
End If
End If
Fin:
End Sub
Private Sub Workbook_Open()
With Feuil1
Application.ScreenUpdating = False
.[H4:H1000].Clear
For L = 4 To .[F65500].End(xlUp).Row
If .Cells(L, "F") <> "" And .Cells(L, "G") <> "" Then
.Cells(L, "H") = "Ok"
ElseIf .Cells(L, "F") < Date And .Cells(L, "G") = "" Then
.Cells(L, "H") = "Relance"
.Cells(L, "H").Font.Color = vbRed
.Cells(L, "H").Font.Bold = True
ElseIf .Cells(L, "F") > Date And .Cells(L, "G") = "" Then
' Calcul du temps avant relance, à supprimer si non necessaire.
.Cells(L, "H") = "Relance dans " & .Cells(L, "F") - Date & " jours."
.Cells(L, "H").Font.Italic = True
End If
Next L
End With
End Sub
Mais n'ai eu aucune réponse de la part de Amymone. Donc c'est resté dans l'état.Dans l'état on regarde juste si F et G est non vide, sans se préoccuper si ce sont des dates ou non.
Donc on peut l'affiner et l'améliorer au besoin.
Je n'avais pas fait le rapport avec l'aspect sécurité sur les dates.la formule est parfaite
Sub test()
L = 1
With Feuil1
If .Cells(L, "F") <> "" And .Cells(L, "G") <> "" Then
texte = "ok" & vbCrLf
ElseIf .Cells(L, "F") < Date And .Cells(L, "G") = "" Then
texte = texte & "Relance" & vbCrLf
texte = texte & "couleur=" & vbRed & vbCrLf
texte = texte & "Bold =" & True
ElseIf .Cells(L, "F") > Date And .Cells(L, "G") = "" Then
' Calcul du temps avant relance, à supprimer si non necessaire.
texte = texte & "Relance dans " & .Cells(L, "F") - Date & " jours."
texte = texte & "Italic =" & True
End If
End With
MsgBox texte
End Sub