Looping through charts in a worksheet

  • Thread starter Thread starter Grant
  • Start date Start date
G

Grant

Hi there, I am sorting of blundering through this. I am
trying to get the following working:


For Each chtObj In ActiveSheet
ActiveSheet.ChartObjects(chtObj).Activate

'Make the data labels bold
ActiveChart.SeriesCollection(1).DataLabels.Select
Selection.Font.Bold = True

'Update the bars to a different colour
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Shadow = False
Selection.InvertIfNegative = False
With Selection.Interior
.ColorIndex = 37
.Pattern = xlSolid
End With
Next chtObj


Any help appreciated,

Grant.
 
Hi Grant,

Try this modified code,

Sub X()
Dim chtObj As ChartObject
For Each chtObj In ActiveSheet.ChartObjects
With chtObj.Chart
'Make the data labels bold
If .SeriesCollection(1).HasDataLabels Then
.SeriesCollection(1).DataLabels.Font.Bold = True
End If
'Update the bars to a different colour
With .SeriesCollection(1)
With .Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
.Shadow = False
.InvertIfNegative = False
With .Interior
.ColorIndex = 37
.Pattern = xlSolid
End With
End With
End With
Next chtObj
End Sub

Cheers
Andy
 
Back
Top