Salut Ray,
sans remettre en cause le moins du monde la justesse des réflexions de Steelson et jmd (salut Messeigneurs), j'ai repris ton fichier et singulièrement simplifié son code.
Hormis la fonction, il ne reste que :
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
'
Dim iTRow%, sCol As String
'
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
'
If Not Intersect(Target, Union(Range("B:B"), Range("D:D"))) Is Nothing Then
If Target <> "" Then
iTRow = Target.Row
sCol = IIf(Target.Column = 2, "B", "D")
Range(sCol & Target.Row).Characters(1, 1).Font.ColorIndex = 5
Range("E" & Target.Row).FormulaLocal = "=SI(C" & iTRow & ">1;E" & iTRow - 1 & "-C" & iTRow & ";"""")"
End If
End If
'
Columns.AutoFit
Application.EnableEvents = True
'
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'
Dim iTRow%
'
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
'
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Range("A" & Rows.Count).End(xlUp).Value <> WorksheetFunction.Proper(Application.Text(Date, "[$-080c]dddd dd mmmm yyyy")) Then
iTRow = Target.Row
If Range("B" & Rows.Count).End(xlUp).Row - iTRow < 5 Then Rows(iTRow + 1).Insert: Rows(iTRow).Font.Color = RGB(0, 0, 0): Range("C" & iTRow).Font.Color = RGB(255, 0, 0)
Target = WorksheetFunction.Proper(Application.Text(Date, "[$-080c]dddd dd mmmm yyyy"))
Range("A" & iTRow).Characters(1, 1).Font.ColorIndex = 3
Range("A" & iTRow).Characters(InStr(Target, Chr(32)) + 4, 1).Font.ColorIndex = 3
Range("F" & iTRow).FormulaLocal = "=SI(A" & iTRow & "<>"""";fctTotaux(LIGNE());"""")" 'Formule de calcul "Dépenses Jour" colonne (F)
End If
End If
'
Application.EnableEvents = True
'
End Sub
La mise en couleur des lignes-date est confiée à des MFC.
Deux dates identiques ne peuvent être saisies à la suite. Attention, pas de sécurité si tu cliques une cellule vide en [A] entre deux autres dates!!
Bref, j'ai fait le fichier que TU voulais! Tu en fais ce que tu veux!
A+