View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Bob Barnes Bob Barnes is offline
external usenet poster
 
Posts: 134
Default Chart Object Error 91

Thank you. Just tried...

....snippet...Down...
Dim ActiveChart As ChartObject

Set ActiveChart = ActiveSheet.ChartObjects("Chart 16")
Set rPatterns = ActiveSheet.Range("AR6:BH235")

With ActiveChart
For iSeries = 1 To .SeriesCollection.Count <-- Still Error 91 here

....snippet...Up

"EricG" wrote:

Works fine when you actually have a chart selected. Probably the user did
not have a chart selected, hence "ActiveChart" is not defined. That's what
error 91 is telling you.

HTH,

Eric


"Bob Barnes" wrote:

I'm an Access Programmer, but was asked why this proceduire fails w/ Error
91...
I tried setting ..Dim ActiveChart As ChartObject...but it still fails...see
where I have
"<--- Where Error 91 occurs" below. TIA - Bob

Sub ColorBySeriesName()
Dim rPatterns As Range
Dim iSeries As Long
Dim rSeries As Range

Set rPatterns = ActiveSheet.Range("AR6:BH235")

With ActiveChart
For iSeries = 1 To .SeriesCollection.Count <--- Where Error 91 occurs
Set rSeries = rPatterns.Find(What:=.SeriesCollection(iSeries).Na me)
If Not rSeries Is Nothing Then
.SeriesCollection(iSeries).Interior.ColorIndex = _
rSeries.Interior.ColorIndex
End If
Next
End With
End Sub