+ Reply to Thread
Results 1 to 3 of 3

Chart source data range

  1. #1
    Don Rouse
    Guest

    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. #2
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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. #3
    Don Rouse
    Guest

    Re: 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" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1