re
EDIT: modif suite à ton message, reprend cette macro:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("B23:C36")) Is Nothing Then
Dim R As Range
For Each R In Range("B23:C36")
If R.Value > 0 Then R.Interior.ColorIndex = 4 Else R.Interior.ColorIndex = 3
Next
End If
End Sub
Merci Roland, voilà où j'en suis resté
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Intersect(Target, Range("K6:M405")) Is Nothing Then
Target.Select
If Target.Value > 0 Then
Selection.FormatConditions.AddDatabar
Selection.FormatConditions(Selection.FormatConditions.Count).ShowValue = True
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1)
.MinPoint.Modify newtype:=xlConditionValueNumber, newvalue:=0
.MaxPoint.Modify newtype:=xlConditionValueNumber, newvalue:="=$M$405"
End With
With Selection.FormatConditions(1).BarColor
.Color = 5287936
.TintAndShade = 0
End With
ElseIf Target.Value < 0 Then
Selection.FormatConditions.AddDatabar
Selection.FormatConditions(Selection.FormatConditions.Count).ShowValue = True
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1)
.MinPoint.Modify newtype:=xlConditionValueNumber, newvalue:=0
.MaxPoint.Modify newtype:=xlConditionValueNumber, newvalue:="=$K$6"
End With
With Selection.FormatConditions(1).BarColor
.Color = 255
.TintAndShade = 0
End With
End If
End If
Application.EnableEvents = True
End Sub
Le hic, c'est que j'ai besoin que celà se déclenche sur un changement de valeur issue de FORMULES. Mon Range K6:M405 ne contient que des cellules à formule.
Hors je ne sais pas le faire proprement pour un range... (j'ai trouvé une méthode fonctionnelle seulement de cellule à cellule, isolée)