Series collection exists

  • Thread starter Thread starter Harley Feldman
  • Start date Start date
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
 
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
 
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
 
Bernie,

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

Thanks,

Harley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top