How to refer to a shape added to a chart

JoeMajestee

New Member
Joined
Jul 15, 2009
Messages
49
I would like to do something with a shape I put on top of a chart by selecting the chart, hitting insert, then an oval. Or something.

If the shape is not connected to the chart, the code is something like this:
VBA Code:
Sheets("Name").Shapes("Oval 6").Fill.ForeColor.RGB = vbGreen
and I can toggle it as needed.

However if I insert onto the chart it seems much more convoluted. I recorded changing the color of my shape and got this:
Code:
    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.Shapes.Range(Array("Oval 1")).Select
    With Selection.ShapeRange.Fill
        .Visible = msoTrue
        .ForeColor.ObjectThemeColor = msoThemeColorAccent4
        .ForeColor.TintAndShade = 0
        .ForeColor.Brightness = 0
        .Transparency = 0
        .Solid
    End With

It seems I should be able to manipulate the color of the second shape, "Oval 1" in a similar way, with one or two lines and no selecting.

Most likely I would like to have a couple shapes on the chart that become visible or not based on a goal being met or not. In essence, up arrow is good down arrow is bad.

My ultimate goal is to have the chart embedded in a powerpoint running in kiosk mode which updates as the excel data changes. Bonus for someone who can help with that!

Thanks.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try...

VBA Code:
    ActiveSheet.ChartObjects("Chart 1").Chart.Shapes("Oval 1").Fill.ForeColor.RGB = vbGreen

or

VBA Code:
    ActiveSheet.ChartObjects("Chart 1").Chart.Shapes("Oval 1").Fill.ForeColor.ObjectThemeColor = msoThemeColorAccent4

Hope this helps!
 
Upvote 0
Solution

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

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