+ Reply to Thread
Results 1 to 2 of 2

can't update chart series unless its activated

  1. #1
    Woody
    Guest

    can't update chart series unless its activated

    I'm trying to update the name a series refers to in code. I tried to do it
    like this:

    Sub test()
    Dim sACWPNamedRange

    sACWPNamedRange = "'" & ActiveSheet.Name & "'!" & "ACWP"

    ActiveWorkbook.Names.Add Name:=sACWPNamedRange, _
    RefersTo:=ActiveSheet.Range("C32:I32")

    With ActiveSheet.ChartObjects("Chart 1")
    .SeriesCollection(3).Values = "=" & sACWPNamedRange
    End With

    End Sub

    The last bit there throws error '438':
    Object doesn't support this property or methd.

    If I activate the chart first:

    Sub test()
    Dim sACWPNamedRange

    sACWPNamedRange = "'" & ActiveSheet.Name & "'!" & "ACWP"

    ActiveWorkbook.Names.Add Name:=sACWPNamedRange, _
    RefersTo:=ActiveSheet.Range("C32:I32")

    ActiveSheet.ChartObjects("Chart 1").Activate
    With ActiveChart
    .SeriesCollection(3).Values = "=" & sACWPNamedRange
    End With

    End Sub

    now it works! Why? I think it has something to do with the reference
    returned from the ChartObjects collection...

    Thanks,
    woody

  2. #2
    Ed Ferrero
    Guest

    Re: can't update chart series unless its activated

    Hi Woody,

    Try...

    With ActiveSheet.ChartObjects("Chart 1").Chart
    .SeriesCollection(3).Values = "=" & sACWPNamedRange
    End With

    Same as previous poster, a ChartObject is not a Chart

    Ed Ferrero
    http://edferrero.m6.net

    > I'm trying to update the name a series refers to in code. I tried to do
    > it
    > like this:
    >
    > Sub test()
    > Dim sACWPNamedRange
    >
    > sACWPNamedRange = "'" & ActiveSheet.Name & "'!" & "ACWP"
    >
    > ActiveWorkbook.Names.Add Name:=sACWPNamedRange, _
    > RefersTo:=ActiveSheet.Range("C32:I32")
    >
    > With ActiveSheet.ChartObjects("Chart 1")
    > .SeriesCollection(3).Values = "=" & sACWPNamedRange
    > End With
    >
    > End Sub
    >
    > The last bit there throws error '438':
    > Object doesn't support this property or methd.
    >
    > If I activate the chart first:
    >
    > Sub test()
    > Dim sACWPNamedRange
    >
    > sACWPNamedRange = "'" & ActiveSheet.Name & "'!" & "ACWP"
    >
    > ActiveWorkbook.Names.Add Name:=sACWPNamedRange, _
    > RefersTo:=ActiveSheet.Range("C32:I32")
    >
    > ActiveSheet.ChartObjects("Chart 1").Activate
    > With ActiveChart
    > .SeriesCollection(3).Values = "=" & sACWPNamedRange
    > End With
    >
    > End Sub
    >
    > now it works! Why? I think it has something to do with the reference
    > returned from the ChartObjects collection...
    >
    > Thanks,
    > woody




+ 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