Hi, I have code that will change data labels, now I want to loop through all the worksheets and change chart 2. Not every sheet has a chart, but if there are charts there is a chart 1 2 and 3.
My current code activates chart 2 and then changes it, but that doesn't work with looping and I'm stuck on how to reference it.
Portion of code below
Dim WSC As Integer
Dim I As Integer
WSC = ActiveWorkbook.Worksheets.Count
For I = 1 To WSC
Dim s1p1, s1p2, s1p3, s1p4 As Long
Dim s2p1, s2p2, s2p3, s2p4 As Long
ActiveSheet.ChartObjects("Chart 2").Activate
s1p1 = CLng(ActiveChart.SeriesCollection(6).Points(1).DataLabel.Text)
s1p2 = CLng(ActiveChart.SeriesCollection(6).Points(2).DataLabel.Text)
s1p3 = CLng(ActiveChart.SeriesCollection(6).Points(3).DataLabel.Text)
s1p4 = CLng(ActiveChart.SeriesCollection(6).Points(4).DataLabel.Text)
s2p1 = CLng(ActiveChart.SeriesCollection(5).Points(1).DataLabel.Text)
s2p2 = CLng(ActiveChart.SeriesCollection(5).Points(2).DataLabel.Text)
s2p3 = CLng(ActiveChart.SeriesCollection(5).Points(3).DataLabel.Text)
s2p4 = CLng(ActiveChart.SeriesCollection(5).Points(4).DataLabel.Text)
'point 1
If s1p1 > s2p1 Then
ActiveChart.SeriesCollection(6).Points(1).DataLabel.Position = xlLabelPositionAbove
ActiveChart.SeriesCollection(5).Points(1).DataLabel.Position = xlLabelPositionBelow
Else: ActiveChart.SeriesCollection(6).Points(1).DataLabel.Position = xlLabelPositionBelow
ActiveChart.SeriesCollection(5).Points(1).DataLabel.Position = xlLabelPositionAbove
End If
'more code...
Next I
'end
Thank you.
Bookmarks