1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Sub test()
Dim cel As Range
Set cel = Range("F10")
cel.Interior.Color = SameColor(cel, Range("R:NZ"))
'adaptation dans une boucle
'for each cel in range("F1:F20")
' cel.Interior.Color = SameColor(cel, Range("R:NZ"))
'Next
End Sub
'
'
Function SameColor(cel As Range, Rng As Range)
For Each cels In Rng.Rows(cel.Row).Cells
Select Case cels.Interior.Color
Case 5287936, 5296274, etc ' mettre toutes eventuelles couleurs ici, c'est la premiere couleur trouvée qui sera pris en compte
SameColor = cels.Interior.Color: Exit For
Case Else: SameColor = xlNone
End Select
Next
End Function |
Partager