I have a problem with a sub which correctly assigns formatting to a chart sheet - but only with launched with the chart visible. Otherwise it applies only one last piece of around 10 formatting steps indicated.
Details: I've got a workbook composed of a few dozens of visible data sheets (along with a few invisible ones) and several visivle chart sheets (sheets containing solely a chart) scattered across the file. I want to assign certain formatting to each visible data sheet and chart. For that reason I created one sub to format sheets, another - for charts. These are called in by a general sub which checks name of each sheet in the workbook, based on which it's discerning data sheets from the graphical ones.
Here's the general sub to launch the other two
Sub Total_update()
Dim Shtnm As String
For i = 1 To ActiveWorkbook.Sheets.Count
Shtnm = ActiveWorkbook.Sheets(i).Name
If Left(ActiveWorkbook.Sheets(i).Name, 1) = "P" Then
Call Number_update(Shtnm)
ElseIf Right(ActiveWorkbook.Sheets(i).Name, 1) = ")" Then
Call Chart_update(Shtnm)
End If
Next i
End Sub
The Number_update sub works flawlessly.
Here's the problematic chart_update sub
Sub Chart_update(Shtnm As String)
Dim iTested As Integer
iShapes = ActiveSheet.Shapes.Count
iTested = 0
Charts(Shtnm).Activate
ActiveChart.Axes(xlCategory).Format.Line.ForeColor.RGB = RGB(0, 0, 0)
ActiveChart.Axes(xlCategory).Format.Line.ForeColor.RGB = RGB(1, 1, 1)
'(several other formatting commands in For loops)
iTested = 2
ActiveChart.SeriesCollection(1).Select
For k = 1 To iTested
ActiveChart.SeriesCollection(1).Points(k).Select
Selection.Format.Fill.ForeColor.RGB = RGB(3, 3, 3) 'Recoloring certain points only from the 1st series
Next k
ActiveChart.SeriesCollection(2).Select 'Selecting 2nd series
Selection.Format.Fill.ForeColor.RGB = RGB(4, 4, 4)
End Sub
Only the last command is implemented even if launched from outside the chart sheet. All the others require manual Alt+F8 sub launch from given chart sheet
Please let me know what am I missing here?