+ Reply to Thread
Results 1 to 6 of 6

Thread: How to select a chart within a worksheet?

  1. #1
    Registered User
    Join Date
    01-27-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    72

    Post How to select a chart within a worksheet?

    I need open a chart to edit, but I can't select it. I made many examples of charts, so I've tried to open one, but it's not working:

    Sub editanomeserie()
    Charts(1).Select
    ActiveChart.SeriesCollection(4).Name = "Nova"
    End Sub

  2. #2
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: How to select a chart within a worksheet?

    Try selecting ChartObjects(1) instead of Chart(1).
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    01-27-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: How to select a chart within a worksheet?

    It's not working either.
    With Charts(1).select, error 9

  4. #4
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: How to select a chart within a worksheet?

    Maybe
    ChartObjects(1).Charts(1).SeriesCollection(4).Name = "Nova"
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  5. #5
    Registered User
    Join Date
    01-27-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: How to select a chart within a worksheet?

    I did this code trying to study something else about this topic.
    Sub Experience()
        Dim MyGraf As ChartObject
        Dim lastcell As Long
        Debug.Print ActiveChart.Parent.Index
        Range("A2").Select
        ActiveSheet.ChartObjects(1).Select
        Set MyGraf = ActiveSheet.ChartObjects(1)
        lastcell = MyGraf.Chart.SeriesCollection.Count
        MyGraf.Chart.SeriesCollection(lastcell).Name = "LastCell"
    End Sub
    Now, it's working, thanks.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,351

    Re: How to select a chart within a worksheet?

    It would be
    Activesheet.ChartObjects(1).Chart.SeriesCollection(4).Name = "Nova"
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0