Invert if negative chart error

ManvinderKaur

Board Regular
Joined
Jun 16, 2010
Messages
149
Hi I am using these steps
http://www.andypope.info/charts/Invertneg.htm
to fill color if negative for my bar graph. But it works only when sheet is active. When when I close that excel workbook and open again. color of bar chart change automatically from red and green to blue and white. I could not figure out why color change automatically whenever I open my sheet again. I was trying to call following sub when sheet become active but that give error 1004 in line 2. I was trying to assign macro to chart. But that works only if I select chart. Is there any solution
Code:
'Formating of Financial saving based on current production level
Public Sub ColorBar()
    [COLOR="Red"]ActiveSheet.ChartObjects("Chart 64").Activate[/COLOR] ' error here
    ActiveChart.SeriesCollection(1).Select
    Selection.InvertIfNegative = True
    Selection.Fill.Patterned Pattern:=msoPattern5Percent
    With Selection
        .Fill.ForeColor.SchemeColor = 43
        .Fill.BackColor.SchemeColor = 3
    End With
    With Selection.Interior
        .ColorIndex = 3
        .PatternColorIndex = 43
        .Pattern = xlSolid
    End With
End Sub
http://www.excelforum.com/excel-programming/739390-invert-if-negative-chart-issue.html#post2353397
 
Last edited:

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
The technique won't work in Excel 2007, as Andy says at the bottom of the link you posted. Also the colour palette has changed.
 
Upvote 0

Forum statistics

Threads
1,215,217
Messages
6,123,670
Members
449,115
Latest member
punka6

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