我在 Excel VBA 中遇到了一些问题。当我尝试运行以下代码时;它说:
Error 1004:Unable to get the name property of the series class!
此错误发生在这行代码:(产品之前定义为字符串 Zyvox 等)
If namec.Name = product Then
我应该怎么办?我也尝试过其他的东西
ActiveChart.SeriesCollection(p).name = product
但无济于事!请帮忙!
Public Sub chartBlue()
Dim i As Integer, j As Integer, p As Integer, namec As Series
For i = 4 To Sheets.Count
Sheets(i).Activate
For j = 1 To Sheets(i).ChartObjects.Count
Sheets(i).ChartObjects(j).Activate
ActiveChart.ChartArea.Select
For p = 1 To ActiveChart.SeriesCollection.Count
Set namec = ActiveChart.SeriesCollection(p)
If namec.Name = product Then
namec.Border.ColorIndex = 5
End If
Next p
Next j
' Windows(Reportname).Activate
Sheets(i).Range("A1").Activate
Next i
End Sub