Private Sub Worksheet_Change(ByVal Target As Range)
Dim li As Long
Application.EnableEvents = False
li = Range("A1").CurrentRegion.Rows.Count + 1
lig = li + 2
' MsgBox "li : " & li & ", lig = " & lig '=11
If Target.Count = 1 Then
'Si "e" renseigné
If Target.Column = 5 And Target.Row <= Range("A1").End(xlDown).Row And Target.Value = "e" Then
With Range("A" & lig & ":B" & lig + 1).Borders
.LineStyle = xlContinuous
.Weight = xlThin
End With
Range("A" & lig).Value = "Crédit"
Range("B" & lig).Value = "Intitulé"
Range("A" & lig + 1).Value = Range("A" & Target.Row).Value '10000
Range("B" & lig + 1).Value = Range("B" & Target.Row).Value 'T
With Range("A" & lig + 2 & ":C" & lig + 3).Borders
.LineStyle = xlContinuous
.Weight = xlThin
End With
Range("A" & lig + 2).Value = "Verser" ' 20000
Range("B" & lig + 2).Value = "Date" ' 28-12-2007
Range("C" & lig + 2).Value = "Reste" ' 20000
Range("B" & lig + 3).Value = Date
Range("B" & lig + 3).Columns.EntireColumn.AutoFit
Range("C" & lig + 3).Value = Range("A" & lig + 1).Value - Range("A" & lig + 3).Value
Range("A" & lig & ":B" & lig).Font.Italic = True
With Range("A" & lig + 1)
.NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* ""-""??_);_(@_)"
With .Font
.Name = "Arial"
.FontStyle = "Gras"
.Size = 8
.ColorIndex = 11
End With
End With
With Range("B" & lig + 1)
With .Font
'.Bold = True
'.Italic = True
.Name = "Arial"
.FontStyle = "Gras italique"
.Size = 8
.ColorIndex = 2
End With
With .Interior
.ColorIndex = 41
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End With
Range("A" & lig + 2 & ":C" & lig + 2).Font.Italic = True
With Range("A" & lig + 4)
.NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* ""-""??_);_(@_)"
With .Font
.Name = "Arial"
.FontStyle = "Gras"
.Size = 8
.ColorIndex = 10 '11
End With
End With
With Range("C" & lig + 3)
.NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* ""-""??_);_(@_)"
With .Font
.Name = "Arial"
.FontStyle = "Gras"
.Size = 8
'.Strikethrough = False
'.Superscript = False
'.Subscript = False
'.OutlineFont = False
'.Shadow = False
'.Underline = xlUnderlineStyleNone
.ColorIndex = 3
End With
End With
'quand le crédit est renseigné
ElseIf Target.Font.ColorIndex = 10 And IsNumeric(Target.Value) And Target.Offset(0, 2).Value > 0 Then
Range(Target, Target.Offset(0, 2)).Copy
Target.Offset(1, 0).Insert Shift:=xlDown
Application.CutCopyMode = False
Target.Offset(1, 0).Value = 0
Target.Offset(1, 1).ClearContents
End If
End If
Application.EnableEvents = True
End Sub