Colour Data Bars according to cell sign

jsuarez199

New Member
Joined
Jun 21, 2013
Messages
3
Hi guys,

Ive been struggling with this...

I have a table with a range of values (AE6:AE15) for which I want to show data bars inside the cells. I want the data bar configuration to be the shortest bar to correspond to the largest value and viceversa. However, this column has both negative and positive values, and it would be great if I could have the negative values in red and the positives in blue. This is what I have tried so far... Any ideas??

Code:
<code style="margin: 0px; padding: 0px; font-style: inherit;">Range("AE6:AE15").Select    Selection.FormatConditions.AddDatabar    Selection.FormatConditions(Selection.FormatConditions.Count).ShowValue = True    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority    With Selection.FormatConditions(1)        .MinPoint.Modify newtype:=xlConditionValueLowestValue        .MaxPoint.Modify newtype:=xlConditionValueHighestValue    End With        For N = 6 To 15    If Cells(N, 31) >= 0 Then    Cells(N, 31).Select    With Selection.FormatConditions(1).BarColor        .Color = 13012579        .TintAndShade = 0    End With    Else    Cells(N, 31).Select    With Selection.FormatConditions(1).BarColor        .Color = 5920255        .TintAndShade = 0    End With        End If        Next
</code>
Thanks in advance!!
 
Last edited:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top