Change progress bar color based on result

MARJ -  
 Exceltutofr -
Hello,

I successfully installed a progress bar in my Excel table cell using conditional formatting.

So I have a bar that progresses according to whether my result is 40 out of 100 or 75 out of 100, etc.

But I would also like this bar to be red when my result ranges between 0 and 50. Then, it should turn green when the result rises between 51 and 100.

How can I do that?

Thanks to anyone who can help me and have a great day,

Configuration: Windows / Chrome 51.0.2704.103

2 réponses

Vaucluse Posted messages 27336 Registration date   Status Contributeur Last intervention   6 453
 
Hello
I don't think it's possible (-but I don't know everything); All we can imagine is a "neutral" color bar with a complementary conditional formatting where the base cell background is red that turns green if the value <50, (or one conditional formatting for green and one for red) but that will only allow spotting the cells below and above average without changing the color of the bar.
Best regards

The quality of the response mainly depends on the clarity of the question, thank you!
2
Mike-31 Posted messages 18405 Registration date   Status Contributeur Last intervention   5 145
 
Hello,

it's possible but in VBA, example to process the range A2:A50
right-click on the tab of your sheet/View code, paste this code

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A2:A50")) Is Nothing Then
Target.FormatConditions.AddDatabar
With Target.FormatConditions(1)
.MinPoint.Modify newtype:=xlConditionValueNumber, newvalue:=0
.MaxPoint.Modify newtype:=xlConditionValueNumber, newvalue:=100
Select Case Target.Value
Case 0 To 50
.BarColor.Color = vbRed
Case 51 To 100
.BarColor.Color = vbGreen
End Select
End With
End If
End Sub


--
Best regards
Mike-31

A period of failure is a perfect time to sow the seeds of knowledge.
0
Exceltutofr
 

A food for thought in video and without macros! :)

https://www.instagram.com/reel/CnAY_5BDPXp/?igshid=YmMyMTA2M2Y%3D

See you soon

@exceltutofr

0