VBA/ Macros Conditional formatting Bar graph

Jzfbkr

New Member
Joined
Aug 4, 2014
Messages
29
Im wondering if anyone can help me im looking to make a large number of histograms change colour depending on the bar value.

If the value is below 0 (<0) I need the bar to be green RBG (0,255,0)
if the value is above 0 (>0) i need the bar to change red RBG (255,0,0)

Does anyone have any ideas of how I can achieve this.

Any help will be greatly appreciated.

Regards,

Joe
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Im wondering if anyone can help me im looking to make a large number of histograms change colour depending on the bar value.

If the value is below 0 (<0) I need the bar to be green RBG (0,255,0)
if the value is above 0 (>0) i need the bar to change red RBG (255,0,0)

Does anyone have any ideas of how I can achieve this.

Any help will be greatly appreciated.

Regards,

Joe

What you can do is use your macro recorder to get some of the language set up. Click on one data point and change the color to whatever you want to use then you can add an If statement to get a macro to update the colors of data points.

So, it might look like this

Code:
If Range("A1").Value > Range("B1").Value Then
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.SeriesCollection(1).Points(5).Select
    With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorAccent1
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Solid
    End With
ElseIf Range("A1").Value < Range("B1").Value Then
     With Selection.Format.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorAccent2
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
        .Solid
    End With
End If
 
Upvote 0
Firstly, Thanks for your reply, I'm very new to using macros so I need to make this function as simple as possible. Is there is a simpler way to achieve?

Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,958
Latest member
Hat4Life

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