Private Sub Worksheet_Change(ByVal Target As Range) Dim colorons As String, couleur As Integer If Not Intersect(Target, Range("R14,S13,T14,U13")) Is Nothing Then Select Case Target.Address(False, False) Case "R14": colorons = "B22:B24" Case "S13": colorons = "C13:C15" Case "T14": colorons = "D22:D24" Case "U13": colorons = "E13:E15" End Select Select Case Target.Text Case "Gscc": couleur = 40 Case "": couleur = -4142 End Select Range(colorons).Interior.ColorIndex = couleur End If End Sub
Deux solutions, dans un tel cas. Les deux présentent des avantages et des inconvénients.
mais au prix, alors, de lenteurs ajoutées
Private Sub Worksheet_Change(ByVal Target As Range) Dim i As Integer, j As Integer, haha, hoho If Not Intersect(Target, Range("AH7,AJ6,AL7,AN6")) Is Nothing Then haha = Array("AH7", "B22:B24", "AJ6", "C13:C15", "AL7", "D22:D24", "AN6", "E13:E15") hoho = Array("Gscc", 40, "", -4142) For i = 0 To UBound(haha) Step 2 If Not Intersect(Target, Range(haha(i))) Is Nothing Then For j = 0 To UBound(hoho) Step 2 If Target.Value = hoho(j) Then Worksheets("resul").Range(haha(i + 1)).Interior.ColorIndex = hoho(j + 1) Exit For End If Next Exit For End If Next End If End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionD'où TOUJOURS la nécessité d'être très complet et précis