Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Chart source data range

I am trying to add charts where the source data range is variable. The
following code gives me a "91" error "Object variable not set. It does not
like the activecell reference for the range.

How can I get around this problem?

Sub AddChart()
Charts.Add
ActiveChart.ChartType = xl3DColumn
ActiveChart.SetSourceData
Source:=Sheets(myDivision).Range(ActiveCell.Offset (1, 0),
ActiveCell.End(xlDown).Offset(0, 2)), _
PlotBy:=xlColumns

Thank you for your assistanve.

Don
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Chart source data range

Is the activesheet mydivision? Mydivision defined? If not, there's your
huckleberry.


Sub AddChart()

Dim rng as Range
With Sheets(myDivision)
set rng = .Range(.Range("A2"), _
.Range("A2").End(xlDown).Offset(0, 2))
End with
Charts.Add
ActiveChart.ChartType = xl3DColumn
ActiveChart.SetSourceData _

Source:=rng, _
PlotBy:=xlColumns



--
Regards,
Tom Ogilvy

"Don Rouse" wrote in message
...
I am trying to add charts where the source data range is variable. The
following code gives me a "91" error "Object variable not set. It does

not
like the activecell reference for the range.

How can I get around this problem?

Sub AddChart()
Charts.Add
ActiveChart.ChartType = xl3DColumn
ActiveChart.SetSourceData
Source:=Sheets(myDivision).Range(ActiveCell.Offset (1, 0),
ActiveCell.End(xlDown).Offset(0, 2)), _
PlotBy:=xlColumns

Thank you for your assistanve.

Don



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Chart source data range

Tom,

That works for me. Thank you for the assistance.

Don

"Tom Ogilvy" wrote:

Is the activesheet mydivision? Mydivision defined? If not, there's your
huckleberry.


Sub AddChart()

Dim rng as Range
With Sheets(myDivision)
set rng = .Range(.Range("A2"), _
.Range("A2").End(xlDown).Offset(0, 2))
End with
Charts.Add
ActiveChart.ChartType = xl3DColumn
ActiveChart.SetSourceData _

Source:=rng, _
PlotBy:=xlColumns



--
Regards,
Tom Ogilvy

"Don Rouse" wrote in message
...
I am trying to add charts where the source data range is variable. The
following code gives me a "91" error "Object variable not set. It does

not
like the activecell reference for the range.

How can I get around this problem?

Sub AddChart()
Charts.Add
ActiveChart.ChartType = xl3DColumn
ActiveChart.SetSourceData
Source:=Sheets(myDivision).Range(ActiveCell.Offset (1, 0),
ActiveCell.End(xlDown).Offset(0, 2)), _
PlotBy:=xlColumns

Thank you for your assistanve.

Don




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
Data Validation to range names for Chart Source Data Candyman Charts and Charting in Excel 1 September 3rd 09 07:27 PM
Using a named range as a data source for a chart MichaelR Charts and Charting in Excel 4 June 16th 08 04:15 AM
Using a named range as a data source for a chart MichaelR Excel Worksheet Functions 0 June 15th 08 01:34 AM
Using a Named Range for Data Source In A Chart JoeP Charts and Charting in Excel 2 April 25th 07 02:33 AM
change chart source from range to raw data daithimcc Excel Programming 2 December 27th 03 05:19 PM


All times are GMT +1. The time now is 09:40 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"