Series collection exists

H

Harley Feldman

I have a pivot table with 69 columns and 42 rows created with VB from another table of values. I am trying to loop through the seriescollection representing each of the columns. I have noticed that I cannot refer to seriescollection(i) when that set of y-values (column) has no values in it. I receive the message: "Select method of Series class failed." Run time error '1004'. Is there a test that I can do in the code to avoid trying to refer to these empty seriescollections?

Harley
 
B

Bernie Deitrick

Harley,

You can use an On Error Goto statement to simply skip over those errors:

Sub test()
Dim i As Integer

On Error GoTo NoSeries:

For i = 1 To 69
Set mySeries = whatever(i)....

'Do other stuff here

NoSeries:
Next i
End Sub

HTH,
Bernie
MS Excel MVP

I have a pivot table with 69 columns and 42 rows created with VB from
another table of values. I am trying to loop through the seriescollection
representing each of the columns. I have noticed that I cannot refer to
seriescollection(i) when that set of y-values (column) has no values in it.
I receive the message: "Select method of Series class failed." Run time
error '1004'. Is there a test that I can do in the code to avoid trying to
refer to these empty seriescollections?

Harley
 
B

Bernie Deitrick

Harley,

Sorry, that will only handle one error. To handle multiple errors:

Sub test()
Dim i As Integer

On Error GoTo NoSeries:
For i = 1 To 69
Set mySeries = whatever(i)....
'Do other stuff here
noErr:
Next i

NoSeries: Resume noErr
End Sub

HTH,
Bernie
MS Excel MVP
 
H

Harley Feldman

Bernie,

It works like a champ. I keep forgetting about the On Error process.

Thanks,

Harley
 
Top