Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Run Time Error 91

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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Run Time Error 91

You get that error when you aere working with an Object variable and then try
to assign to it as though it were a "normal" variable. To assign to an
Object variable you neeed to use the Set keyword, e.g. Set MyObject =
ActiveChart
--
Time is just the thing that keeps everything from happening all at once


"Qaspec" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Run Time Error 91

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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
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.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Run Time Error 91


I ran your code on a column chart in XL2002 with no problems.
--
Jim Cone
Portland, Oregon USA



"Qaspec"

wrote in message
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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Run Time Error 91

Then is it xl2003? Maybe my method of placement? I placed the code in vba
project in a module and went to the chart and assigned the macro from there.
At that point I click on the chart to run the macro is where I get the error
message. My Macro security is set to low, and trust all sources, and allow
access to vba project.

I did notice that when I searched for the ActiveChart object in the vba
object browser it gave me a message saying it was hidden.

"Jim Cone" wrote:


I ran your code on a column chart in XL2002 with no problems.
--
Jim Cone
Portland, Oregon USA



"Qaspec"

wrote in message
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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Run Time Error 91

Change the unwilling line to...
With ActiveSheet.ChartObjects(1).Chart.SeriesCollection (1)

The above assumes there is only one chart on the sheet or that
it is the first chart that was added to the sheet.
--
Jim Cone
Portland, Oregon USA




"Qaspec"
wrote in message
Then is it xl2003? Maybe my method of placement? I placed the code in vba
project in a module and went to the chart and assigned the macro from there.
At that point I click on the chart to run the macro is where I get the error
message. My Macro security is set to low, and trust all sources, and allow
access to vba project.
I did notice that when I searched for the ActiveChart object in the vba
object browser it gave me a message saying it was hidden.




"Jim Cone" wrote:
I ran your code on a column chart in XL2002 with no problems.
--
Jim Cone
Portland, Oregon USA


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Error handling error # 1004 Run-time error [email protected] Excel Programming 3 May 20th 08 02:23 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM


All times are GMT +1. The time now is 12:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"