+ Reply to Thread
Results 1 to 4 of 4

VBA to change a charts name

  1. #1
    Registered User
    Join Date
    06-25-2012
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    14

    VBA to change a charts name

    First foray into VBA Created charts and I'm losing my mind. I have a macro that creates a chart based on the data that is selected in a listbox userform. I wanted to name the chart based on a string variable that I set through the user form but I can't even get name it anything right now. I've attached the first half of the macro code, the last line is where I am erroring.

    Please Login or Register  to view this content.

    I want to say ActiveChart.Name = "" & chartit & "" in a perfect world because that would give each chart a unique name based on its data set. Help?

  2. #2
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA to change a charts name

    try naming the containing chartobject
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  3. #3
    Registered User
    Join Date
    06-25-2012
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: VBA to change a charts name

    Thank you that took care of it. I am also wondering how can I tell the chart where to land/move once it is created. I want to have the upper left corner of the first chart start in A1 and have subsequent charts start below. I was planning on using a loop to place a value in a cell below each chart as it was created and use that to reference the spot for the next chart to start at but my charts are landing in the middle of the page. Any ideas what I can do? Same code but I am attaching all of it now, w/ edits I've made. Everything works fine, just need to know what to do to get the chart to refernce a specific cell upon creation.

    Please Login or Register  to view this content.
    Thanks!

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: VBA to change a charts name

    the shapes.addchart method allows you to specify the chart type and position when you add the chart so you can use a loop
    Please Login or Register  to view this content.

+ 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