Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel Conditional Formatting Data Bars based on Color

I cannot find a way to change the color of an Excel data bar based on value. Current formatting options only permit different colors based on positive/negative values. I'm currently using Excel 2010.

I would like to have the color of a data bar show up as 'red' if the value if between 0-0.3, 'yellow' if the value is between 0.3-0.6, and 'green' if the value if between >0.6.

Would really appreciate any info people could share.

Thanks,

TB

like image 994
TheBlake Avatar asked Jun 04 '15 01:06

TheBlake


People also ask

Can conditional formatting be used for data bars?

Data bars, color scales, and icon sets are conditional formats that create visual effects in your data. These conditional formats make it easier to compare the values of a range of cells at the same time.

How do you conditionally format a bar graph in Excel?

To add conditional formatting with data bars, follow these steps. On the Excel worksheet, select the cells with numbers that you want to format. Do NOT include any row or column totals. On the Ribbon, click the Home tab, and then in the Styles group, click Conditional Formatting.


2 Answers

Data bars only support one color per set. The idea is that the length of the data bar gives you an indication of high, medium or low.

Conditional colors can be achieved with color scales.

What you describe sounds like a combination of the two, but that does not exist in Excel and I don't see an easy way to hack it.

You could use a kind of in-cell "chart" that was popular before sparklines came along. Use a formula to repeat a character (in the screenshot it's the character g formatted with Marlett font), and then use conditional formatting to change the font color.

enter image description here

For a nicer "bar" feel, use unicode character 2588 with a regular font.

enter image description here

Edit: Not every Unicode character is represented in every font. In this case the the unicode 2588 shows fine with Arial font but not with Excel's default Calibri. Select your fonts accordingly. The Insert > Symbol dialog will help find suitable characters.

enter image description here

like image 124
teylyn Avatar answered Sep 30 '22 12:09

teylyn


I setup conditional formatting in the cell adjacent to the data bar that changes color based on the value in the target cell (green, yellow, red, orange). I then loop through the VBA below to update the data bar color based on the conditional formatting in the adjacent cell.

Dim intCount As Integer
Dim db As DataBar

On Error Resume Next
For intCount = 9 To 43 'rows with data bars to be updated
    Worksheets("Worksheet Name").Cells(intCount, 10).FormatConditions(1).BarColor.Color = Worksheets("Worksheet Name").Cells(intCount, 11).DisplayFormat.Interior.Color
Next intCount
like image 33
clarencebuttowski Avatar answered Sep 30 '22 13:09

clarencebuttowski