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
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
16,669
Have you tried changing this line:

With ActiveSheet.Shapes(MyChart).Line

to this:

With ActiveChart.Line
 

Brorenzo

New Member
Joined
Jul 24, 2017
Messages
15
No dice. Same issue with .Line instead of .Border.



 
Last edited:

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
16,669
You need to get the correct syntax - maybe:

With ActiveChart.SeriesCollection(1).Border
.Color = RGB(63, 63, 63)
End With
 

Brorenzo

New Member
Joined
Jul 24, 2017
Messages
15
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.
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
16,669
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.
 

Forum statistics

Threads
1,082,629
Messages
5,366,645
Members
400,908
Latest member
currong

Some videos you may like

This Week's Hot Topics

Top