How do you handle Run-time error '1004'? I ave gotten it under several different cases. There is the one I am having issues with now.
I am trying to write a loop that goes trough all Series of all graphs in a workbook, and only act on ones names "Spec". I am using te following method:
For Each WorkChart in ActiveWorkbook.Charts
For Each WorkSeries in WorkChart.SeriesCollection
If WorkSeries.Name = "Spec" Then
...
endif
Next WorkSeries
Next WorkChart
The issue is, if a series gets deleted, it leaves a "undefined" series in its place. When it tries to get the .Name of this undefined series, it causes the Runtime Error 1004. Is there any way to test if a property such as .Name is defined before trying to use it?
Thanks.
I am trying to write a loop that goes trough all Series of all graphs in a workbook, and only act on ones names "Spec". I am using te following method:
For Each WorkChart in ActiveWorkbook.Charts
For Each WorkSeries in WorkChart.SeriesCollection
If WorkSeries.Name = "Spec" Then
...
endif
Next WorkSeries
Next WorkChart
The issue is, if a series gets deleted, it leaves a "undefined" series in its place. When it tries to get the .Name of this undefined series, it causes the Runtime Error 1004. Is there any way to test if a property such as .Name is defined before trying to use it?
Thanks.