+ Reply to Thread
Results 1 to 7 of 7

Select a chart from a chartsheet in VBA

  1. #1
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Select a chart from a chartsheet in VBA

    I'm trying to write some code that will select a chart froim a chartsheet to copy it, but I can't seem to get it work.
    I had a similar code to select a chart that was part of a worksheet that worked fine.

    the line I'm using is

    Please Login or Register  to view this content.
    But I get the error - The item with the specified name wasn't found
    the name of the tab and the charts are both STP% Chart
    Any ideas please?

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,626

    Re: Select a chart from a chartsheet in VBA

    first: if tou try to assign chartobject, it shall be done with Set instruction
    second: shouldnt it refer to named chcart in current sheet, like
    Please Login or Register  to view this content.
    ?
    Best Regards,

    Kaper

  3. #3
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: Select a chart from a chartsheet in VBA

    hi

    that still doesn't work, same error

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,626

    Re: Select a chart from a chartsheet in VBA

    Some errors are obvious, some less. While in case of obvious one, sample file is useless, for "not so obvious" case attachment could clarify a lot :-)

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Select a chart from a chartsheet in VBA

    Isn't the chart sheet itself the chart?
    If posting code please use code tags, see here.

  6. #6
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Shropshire, England
    MS-Off Ver
    Excel 2007 /10 /13
    Posts
    118

    Re: Select a chart from a chartsheet in VBA

    Hi all

    seem to have stumbled on the answer - this does the trick

    Please Login or Register  to view this content.
    thanks all

  7. #7
    Spammer
    Join Date
    01-26-2010
    Location
    Worcester MA
    MS-Off Ver
    Excel 2003
    Posts
    184

    Re: Select a chart from a chartsheet in VBA

    How is Chart2Copy declared? If it's a chart, then it is either this for an embedded chart:

    Set Chart2Copy = ActiveSheet.ChartObjects("STP% Chart").Chart

    or one of these for a chart sheet:

    Set Chart2Copy = ActiveSheet

    Set Chart2Copy = ActiveWorkbook.Sheets("STP% Chart")

    Set Chart2Copy = ActiveWorkbook.Charts("STP% Chart")
    Jon Peltier
    http://PeltierTech.com/

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] There is an error if sheet is "ChartSheet."
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-12-2014, 04:01 PM
  2. [SOLVED] Delete Chartsheet
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-11-2014, 06:27 PM
  3. Replies: 4
    Last Post: 04-15-2014, 02:22 AM
  4. Replies: 0
    Last Post: 04-14-2014, 04:02 AM
  5. Replies: 1
    Last Post: 01-17-2012, 06:43 AM
  6. RangeFromPoint ... on a chartsheet ?
    By MrT in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2006, 09:35 AM
  7. [SOLVED] 1 ChartSheet, 10 worksheets
    By Martin Wheeler in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 01-22-2005, 06:06 PM

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.6.0 RC 1