Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 134
Default Chart Object Error 91

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 220
Default Chart Object Error 91

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Chart Object Error 91

Bob

Replace

<<With ActiveChart
by

With ActiveSheet.ChartObjects(1).Chart
(if you have only one chart)

OR

With ActiveSheet.ChartObjects("chartname").Chart
(if you have only one chart)

If this post helps click Yes
---------------
Jacob Skaria


"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

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

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 220
Default Chart Object Error 91

Bad idea!

ActiveChart is a built-in Excel object name and refers to the currently
selected chart on a sheet. You should not use that same name for your
variable. Call it something else, like "MyChart" or whatever, just not
ActiveChart.

Did you try just selected a chart on the current worksheet and then running
your original code? If that doesn't work, try Jacob's suggestion.

HTH,

Eric


"Bob Barnes" wrote:

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



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default Chart Object Error 91

Oops. I should have removed the comment "(if you have only one chart)
" from the second option. If you have more more number of charts; specify
the name..

With ActiveSheet.ChartObjects(1).Chart
(if you have only one chart)

OR

With ActiveSheet.ChartObjects("Chart 16").Chart
(if you have multiple chart objects)

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Bob

Replace

<<With ActiveChart
by

With ActiveSheet.ChartObjects(1).Chart
(if you have only one chart)

OR

With ActiveSheet.ChartObjects("chartname").Chart
(if you have only one chart)

If this post helps click Yes
---------------
Jacob Skaria


"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

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 134
Default Chart Object Error 91

With ActiveSheet.ChartObjects("Chart 16").Chart
....solved the problem..

Thank you & EricG - Bob

"Jacob Skaria" wrote:

Oops. I should have removed the comment "(if you have only one chart)
" from the second option. If you have more more number of charts; specify
the name..

With ActiveSheet.ChartObjects(1).Chart
(if you have only one chart)

OR

With ActiveSheet.ChartObjects("Chart 16").Chart
(if you have multiple chart objects)

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Bob

Replace

<<With ActiveChart
by

With ActiveSheet.ChartObjects(1).Chart
(if you have only one chart)

OR

With ActiveSheet.ChartObjects("chartname").Chart
(if you have only one chart)

If this post helps click Yes
---------------
Jacob Skaria


"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

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 134
Default Chart Object Error 91

With ActiveSheet.ChartObjects("Chart 16").Chart
....solved the problem..

Thank you & Jacob - Bob


"EricG" wrote:

Bad idea!

ActiveChart is a built-in Excel object name and refers to the currently
selected chart on a sheet. You should not use that same name for your
variable. Call it something else, like "MyChart" or whatever, just not
ActiveChart.

Did you try just selected a chart on the current worksheet and then running
your original code? If that doesn't work, try Jacob's suggestion.

HTH,

Eric


"Bob Barnes" wrote:

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

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
Application/Object defined error? Myles Excel Discussion (Misc queries) 0 March 27th 09 07:48 PM
How do i export a pivot chart as a static chart object? James Charts and Charting in Excel 2 November 11th 08 10:05 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
How do I get rid of the error "can't shift object off sheet" MStuck Excel Discussion (Misc queries) 1 April 29th 05 10:39 PM
error! Not a valid embedded object Shadina Excel Discussion (Misc queries) 0 January 4th 05 11:53 AM


All times are GMT +1. The time now is 09:19 AM.

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

About Us

"It's about Microsoft Excel"