+ Reply to Thread
Results 1 to 4 of 4

Activating a Chart in VBA

  1. #1
    Registered User
    Join Date
    07-06-2011
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    20

    Question Activating a Chart in VBA

    I'm creating a chart in VBA. I have it looping through all my data, and puting the correct information into the correct series. At the very end, I am trying to move this chart into a new tab with this code

    Please Login or Register  to view this content.
    I get an error, basically telling me that I can't do that because the chart isn't selected, so there is not "activechart" to reference.

    Then I go back to the beginning where I add a new chart and enter this,

    Please Login or Register  to view this content.
    And at the end of the document then put,

    Please Login or Register  to view this content.
    However, it never gets to the last part of code, because at the line

    ActiveChart.Name = "(0C)"

    I get an error message that says Run-Time Error 7 "Out Of Memory"


    All I need to do is somehow activate that graph, and then move it to a new tab at the very end of the macro. Any help would me greatly appreciated.

    Thanks

    P.S- I know my names don't all match up.. They do in my VB code, I was just creating a quick example in this document to explain the error I am getting.
    Last edited by ZEvans12; 07-20-2011 at 08:59 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Activating a Chart in VBA

    Why not paste the sample workbook with some typical data/chart and your code ... so everything does match up and the problem can be seen in context.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


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

    Re: Activating a Chart in VBA

    to name the chartobject you need

    Please Login or Register  to view this content.
    Why add the chartobject to a sheet and then move it?
    Why not simply add a chart.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    07-06-2011
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Activating a Chart in VBA

    If I were to add a new chart in the new tab, then I would have to reference the original worksheet when I collected me data, and then re-reference the chart at the end. Just seemed like an unnecessary step in my opinion. But the .parent code worked perfectly. Thank you.

+ 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