Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Unable to get the ChartObjects property ...

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    112
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I am attempting to use the cobbled code below to determine the current axis of a chart series, and then set a cell value to true of false based on that information. When I execute the code I get a runtime error |Unable to get the ChartObjects property of the worksheet class. Can someone point out the error of my ways?

    Regards...Strorg


    ActiveSheet.ChartObjects("Chart 1").Activate
    ActiveChart.SeriesCollection(1).Select
    CurrentAxis = ActiveChart.SeriesCollection(1).AxisGroup

    Application.Goto Reference:="ap1a"
    If CurrentAxis = 1 Then
    ActiveCell.Value = True
    Else: ActiveCell.Value = False
    End If

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi,

    This is probably because the chart isn't called Chart1. The way to check this is to use this code:-

    Sub GetChartNames()
    Dim chtObject As ChartObject
    For Each chtObject In ActiveSheet.ChartObjects
    MsgBox chtObject.Name
    Next
    End Sub

    Then change your code to the correct ChartObject name. An alternative is to use this instead:-

    ActiveSheet.ChartObjects(1).Activate

    This may not work if you have more than one chart on the active sheet.

    HTH,
    Dan

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Posts
    112
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks for the tip. My error was too obvious...I wasn't selecting the sheet. DUH. Thanks for the troubleshooting tip with the message box. I'll use it in the future.

    Regards...Tom

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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