+ Reply to Thread
Results 1 to 4 of 4

Charting and VBA

  1. #1
    Forum Contributor
    Join Date
    04-08-2008
    Posts
    121

    Charting and VBA

    Hi - I'm trying to set up buttons for my graphs that I can click on when I want a particular graph to come up. At the moment I have each graph on its own sheet but I would like the graph to appear on the data sheet as an object when you click the button.

    Any thoughts on the best way of acheiving this?

    Many Thanks
    Harry

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436
    You could start by using the macro recorder.

    Perform the task of changing the location of 1 of your charts sheets.

    I guess you will also need to record the code for converting a chart object back to a chart sheet.

    You may find changing location alters the layout of the chart as font size may alter, if Auto scaling, when switching between sheet and object.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Contributor
    Join Date
    04-08-2008
    Posts
    121
    Thanks, I've tried that and it seems to come up with an error.

    I've got this code:

    Worksheets("Sheet1").ChartObjects("Chart 1").Activate
    ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= "MyChart"

    This will change the embedded chart, Chart 1 on Sheet 1 to a chart sheet named MyChart.

    I want to do it the other way round, move a chart sheet to a sheet embedded. Shoyuld be quite straight forward, I imagine.

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

    It uses the buttons caption to locate, move and name charts.
    Allow there is a named range for the chartobject to be displayed in.

    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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