1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| Sub Voir()
Dim kR As Long, sCode As String, vDbt As Single, vCdt As Single
Dim c0 As Long, c1 As Long, c2 As Long, c3 As Long, c4 As Long
c0 = Cells(1, 3).Interior.Color
c1 = Cells(1, 4).Interior.Color
c2 = Cells(2, 4).Interior.Color
c3 = Cells(1, 5).Interior.Color
c4 = Cells(2, 5).Interior.Color
kR = ActiveCell.Row
If kR < 5 Or Cells(kR, 1) = "" Then Exit Sub
sCode = Cells(kR, 1)
vDbt = Cells(kR, 9)
vCdt = Cells(kR, 12)
Columns("A:A").Interior.TintAndShade = 0
Columns("I:L").Interior.TintAndShade = 0
Cells(kR, 9).Interior.Color = c0
Cells(kR, 12).Interior.Color = c0
While Cells(kR, 9) <> "" '---colonne débit, à partir de la ligne active
If Cells(kR, 1) = sCode Then
Cells(kR, 1).Interior.Color = c0
If Cells(kR, 9) = vCdt Then
Cells(kR, 9).Interior.Color = c1
ElseIf Cells(kR, 9) >= vCdt - 10 And Cells(kR, 9) <= vCdt + 10 Then
Cells(kR, 9).Interior.Color = c2
ElseIf Cells(kR, 9) = -vDbt Then
Cells(kR, 9).Interior.Color = c3
ElseIf Cells(kR, 9) >= -vDbt - 10 And Cells(kR, 9) <= -vDbt + 10 Then
Cells(kR, 9).Interior.Color = c4
End If
End If
kR = kR + 1
Wend
kR = ActiveCell.Row
While Cells(kR, 12) <> "" '---colonne crédit, à partir de la ligne active
If Cells(kR, 1) = sCode Then
If Cells(kR, 12) = vDbt Then
Cells(kR, 12).Interior.Color = c1
ElseIf Cells(kR, 12) >= vDbt - 10 And Cells(kR, 12) <= vDbt + 10 Then
Cells(kR, 12).Interior.Color = c2
ElseIf Cells(kR, 12) = -vCdt Then
Cells(kR, 12).Interior.Color = c3
ElseIf Cells(kR, 12) >= -vCdt - 10 And Cells(kR, 12) <= -vCdt + 10 Then
Cells(kR, 12).Interior.Color = c4
End If
End If
kR = kR + 1
Wend
End Sub |
Partager