Bonjour à tous,
le code si joint me permet de mettre en couleur les valeurs d'une colonne en fonction d'une case de la même colonne.
je l'ai adapte sur 3 colonnes or mon fichier d'origine comporte + de 200 colonnes. et l'adapter aux 200 est super long.
y a t-il un moyen de faire plus simple avec le code.
merci d'avance
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Plage1 As Range, Plage2 As Range, plage3 As Range
Dim Inter1 As Range, Inter2 As Range, inter3 As Range
Dim i As Long
Set Plage1 = Feuil1.Range("D528")
Set Plage2 = Feuil1.Range("E5:E28")
Set plage3 = Feuil1.Range("F5:F28")
Set Inter1 = Application.Intersect(ActiveCell, Plage1)
Set Inter2 = Application.Intersect(ActiveCell, Plage2)
Set inter3 = Application.Intersect(ActiveCell, plage3)
If Not Inter1 Is Nothing Then
For i = 5 To 28
If Feuil1.Range("D" & i) > Feuil1.Range("D2") Then
Feuil1.Range("D" & i).Interior.ColorIndex = 36
Else
Feuil1.Range("D" & i).Interior.ColorIndex = 0
End If
Next i
End If
If Not Inter2 Is Nothing Then
For i = 5 To 28
If Feuil1.Range("E" & i) > Feuil1.Range("E2") Then
Feuil1.Range("E" & i).Interior.ColorIndex = 36
Else
Feuil1.Range("E" & i).Interior.ColorIndex = 0
End If
Next i
End If
If Not inter3 Is Nothing Then
For i = 5 To 28
If Feuil1.Range("F" & i) > Feuil1.Range("F2") Then
Feuil1.Range("F" & i).Interior.ColorIndex = 36
Else
Feuil1.Range("F" & i).Interior.ColorIndex = 0
End If
Next i
End If
End Sub
le code si joint me permet de mettre en couleur les valeurs d'une colonne en fonction d'une case de la même colonne.
je l'ai adapte sur 3 colonnes or mon fichier d'origine comporte + de 200 colonnes. et l'adapter aux 200 est super long.
y a t-il un moyen de faire plus simple avec le code.
merci d'avance
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Plage1 As Range, Plage2 As Range, plage3 As Range
Dim Inter1 As Range, Inter2 As Range, inter3 As Range
Dim i As Long
Set Plage1 = Feuil1.Range("D528")
Set Plage2 = Feuil1.Range("E5:E28")
Set plage3 = Feuil1.Range("F5:F28")
Set Inter1 = Application.Intersect(ActiveCell, Plage1)
Set Inter2 = Application.Intersect(ActiveCell, Plage2)
Set inter3 = Application.Intersect(ActiveCell, plage3)
If Not Inter1 Is Nothing Then
For i = 5 To 28
If Feuil1.Range("D" & i) > Feuil1.Range("D2") Then
Feuil1.Range("D" & i).Interior.ColorIndex = 36
Else
Feuil1.Range("D" & i).Interior.ColorIndex = 0
End If
Next i
End If
If Not Inter2 Is Nothing Then
For i = 5 To 28
If Feuil1.Range("E" & i) > Feuil1.Range("E2") Then
Feuil1.Range("E" & i).Interior.ColorIndex = 36
Else
Feuil1.Range("E" & i).Interior.ColorIndex = 0
End If
Next i
End If
If Not inter3 Is Nothing Then
For i = 5 To 28
If Feuil1.Range("F" & i) > Feuil1.Range("F2") Then
Feuil1.Range("F" & i).Interior.ColorIndex = 36
Else
Feuil1.Range("F" & i).Interior.ColorIndex = 0
End If
Next i
End If
End Sub