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
|
Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Integer, c As Integer
Dim ArrWd
If Target.Row >= 3 And Target.Row <= 2000 Then
Range("a" & Target.Row & ":dd" & Target.Row).Interior.ColorIndex = -4142 'couleur automatique
r = Target.Row
c = Cells(r, 250).End(xlToLeft).Column
ArrWd = Split("REFUS CAT, CLIENT/PROSPECT INTERNE, SANS AUTO", ", ")
For i = 0 To UBound(ArrWd)
If Cells(r, c) = ArrWd(i) Then
Range("a" & r & ":dd" & r).Interior.ColorIndex = 3 'rouge
Exit Sub
End If
Next i
'on peut ajouter 2 conditions avant de peindre en orange, il faut que la cellule K de la ligne concernée
'ne contiennent ni GE ni GR, ainsi meme si la valeur de cellule est oui, la ligne n'est pas orange.
If Cells(r, c) = "OUI" And Cells(r, 11) <> "GR" And Cells(r, 11) <> "GE" Then
Range("a" & r & ":dd" & r).Interior.ColorIndex = 40 'orange
Exit Sub
Else
If Cells(r, c) = "RDV" Then
Range("a" & r & ":dd" & r).Interior.ColorIndex = 4 'vert
Exit Sub
Else
'Pour le bleu j'applique plutot cette methode qui évite de boucler sur toutes les cellules, perte de temps
'puisque l 'on ne veut tester qu'une cellule dont la valeur de colonne finit par 1 ou 6
If c Like "*1" Or c Like "*6" Then
If Cells(r, c) <> "" Then
Range("a" & r & ":dd" & r).Interior.ColorIndex = 37 'bleu
'40 etant orange, j'ai laissé en 37, bleu
Exit Sub
End If
End If
End If
End If
End Sub |
Partager