Hello dear community,
I need help with loop function in following VBA
How can I make this part "Sheet31.ChartObjects(1).Chart"
to be
Sheet31.ChartObjects(2).Chart
Sheet31.ChartObjects(3).Chart
Sheet31.ChartObjects(4).Chart
etc.. There are around 50 chart objects.
Can anyone help me please?
I need help with loop function in following VBA
VBA Code:
Sub ColorOfChart()
Dim chrt As Chart, i As Long, clr As Long
Dim r As Byte, g As Byte, b As Byte
Set chrt = Sheet31.ChartObjects(1).Chart
For i = 1 To chrt.SeriesCollection.Count
clr = Sheet31.Cells(68, i).Interior.Color
r = clr Mod 256
g = clr \ 256 Mod 256
b = clr \ 65536 Mod 256
chrt.SeriesCollection(i).Format.Fill.ForeColor.RGB = RGB(r, g, b)
Next i
End Sub
How can I make this part "Sheet31.ChartObjects(1).Chart"
to be
Sheet31.ChartObjects(2).Chart
Sheet31.ChartObjects(3).Chart
Sheet31.ChartObjects(4).Chart
etc.. There are around 50 chart objects.
Can anyone help me please?