+ Reply to Thread
Results 1 to 2 of 2

How to move a chart? Can't get the name syntax right

  1. #1
    Registered User
    Join Date
    07-11-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    5

    Question How to move a chart? Can't get the name syntax right

    Hi, newbie here again.

    I created a macro using the recorder, and it gave me this.

    ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select
    ActiveSheet.Shapes("Chart 6").IncrementLeft 261
    ActiveSheet.Shapes("Chart 6").IncrementTop -59.25

    Later on in the macro I name the chart "2000 to 2001" using

    ActiveChart.HasTitle = True
    ActiveChart.ChartTitle.Text = "2000 to 2001"

    I want to move the chart again, but when I use the code:

    ActiveSheet.Shapes("2000 to 2001").IncrementLeft 200

    or

    ActiveSheet.ChartObjects("2000 to 2001").IncrementLeft 200

    Neither work.

    The error I get is "The item with that specified name is not found"

    What is a way I can move the chart by referring to it's title?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,428

    Re: How to move a chart? Can't get the name syntax right

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    You can not use the chart title to automatical create a reference. You would either need to loop through all charts checking whether they had a chart title and then seeing if the text matches. Or name the chart object, which you can use to reference directly
    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)

Similar Threads

  1. Syntax for using a cell reference in the source data field of a chart
    By Grimace in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-21-2013, 11:54 PM
  2. Syntax error in populating data in a chart from a pivot table
    By highlystrung in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2011, 04:41 PM
  3. Proper syntax to move a row to another sheet with a variable involved.
    By Permagrin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-30-2008, 02:05 PM
  4. How to draw a line on a chart, and have it move with the chart?
    By manxman in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-09-2006, 01:40 PM
  5. How do i move a chart
    By ExcelUser123 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 05-17-2006, 04:28 AM

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