View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Qaspec Qaspec is offline
external usenet poster
 
Posts: 96
Default Run Time Error 91

I click the chart in order to run the code and I'm using xl2003.

Here is the macro

Sub ColorByValue()
Dim rPatterns As Range
Dim iPattern As Long
Dim vPatterns As Variant
Dim iPoint As Long
Dim vValues As Variant
Dim rValue As Range

Set rPatterns = ActiveSheet.Range("T1:T3")
vPatterns = rPatterns.Value
With ActiveChart.SeriesCollection(1)
vValues = .Values
For iPoint = 1 To UBound(vValues)
For iPattern = 1 To UBound(vPatterns)
If vValues(iPoint) <= vPatterns(iPattern, 1) Then
.Points(iPoint).Interior.ColorIndex = _
rPatterns.Cells(iPattern, 1).Interior.ColorIndex
Exit For
End If
Next
Next
End With
End Sub

"Jim Cone" wrote:

For the code to execute, there must be a chart that is active.
That means your code must have selected the chart or the chart
must have been selected manually (click the chart) before the code was run.
Also, there must be a Series on the chart.

You should have specified what XL version you are running.

If you are running xl2007, I wouldn't hazard a guess.
--
Jim Cone
Portland, Oregon USA



"Qaspec"

wrote in message
I get the following error message when I try to run a sub in excel 2003:

"Runtime Error 91 Object Variable or With Block Variable Not Set"

I receive the error when the line gets to:
With ActiveChart.SeriesCollection(1)

I'm assuming the means that I need to check one of the libraries in the
references. If I'm incorrect or if anyone knows the correct library for the
SeriesCollection method, please let me know.