For Each Chart Help Needed

Brorenzo

New Member
Joined
Jul 24, 2017
Messages
15
Hi All,

Trying to loop through 72 charts on a single worksheet to update the border color on them. My VBA code fails with a "Type mismatch" on the beginning of the With. Little help please? Code below.


Code:
Sub PivotBorder()    Dim MyChart As ChartObject
    For Each MyChart In ActiveSheet.ChartObjects
        MyChart.Activate
        With ActiveSheet.Shapes(MyChart).Line
            .Visible = msoTrue
            .ForeColor.RGB = RGB(63, 63, 63)
            .Transparency = 0
        End With
    Next MyChart
End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Have you tried changing this line:

With ActiveSheet.Shapes(MyChart).Line

to this:

With ActiveChart.Line
 
Upvote 0
No dice. Same issue with .Line instead of .Border.

Capture.png


Capture.png
 
Last edited:
Upvote 0
You need to get the correct syntax - maybe:

With ActiveChart.SeriesCollection(1).Border
.Color = RGB(63, 63, 63)
End With
 
Upvote 0
Well, it didn't error out that time, but it didn't work as expected either. This ended up changing the line color on the line graphs to (63,63,63), instead of changing the Borders of the charts. :-/

Thanks for trying. I'm going to research and see if there's a command I'm missing.
 
Upvote 0
Well, it didn't error out that time, but it didn't work as expected either. This ended up changing the line color on the line graphs to (63,63,63), instead of changing the Borders of the charts. :-/

Thanks for trying. I'm going to research and see if there's a command I'm missing.
I thought you wanted to change the line color. Good luck with your research.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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