1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Private Sub Worksheet_Change(ByVal Target As Range)
Dim sg As Integer, P As Integer, Q As Integer
On Error GoTo Fin
Application.EnableEvents = False
If Target.Count = 1 Then
If Target.Column = 4 Then
P = InStr("retrait CB_Chèque", Target.Offset(0, -1)) > 0 And Target.Value > 0
Q = InStr("Virement", Target.Offset(0, -1)) > 0 And Target.Value < 0
sg = 2 * (P + Q) + 1
If sg <> 1 Then Target.Value = sg * Target.Value
ElseIf Target.Column = 3 Then
P = InStr("retrait CB_Chèque", Target.Value) > 0 And Target.Offset(0, 1).Value > 0
Q = InStr("Virement", Target.Value) > 0 And Target.Offset(0, 1).Value < 0
sg = 2 * (P + Q) + 1
If sg <> 1 Then Target.Offset(0, 1) = sg * Target.Offset(0, 1)
End If
End If
Fin:
Application.EnableEvents = True
End Sub |
Partager