Solved

Excel 2007 VB To Move & Resize Chart

Posted on 2009-06-30
6
654 Views
Last Modified: 2013-11-26
Hello Experts,

What do I need to modify on the attached code that will capture moving and resizing a chart?  When I look at the macro recorder it only comes up with:
    ActiveSheet.ChartObjects("Chart 6").Activate
    ActiveChart.ChartArea.Select
    ActiveSheet.ChartObjects("Chart 6").Activate
Which generates a 'cannot find defined name' error.  I'm trying to slide the chart to the left and expand it's width.
Thanks
Sheets("Report").Select

    Range("A27").Select

    ActiveSheet.Shapes.AddChart.Select

    ActiveChart.ChartType = xlColumnClustered

    ActiveChart.SetSourceData Source:=Sheets("Pivot Table Data").Range("A25:B42")

    ActiveChart.Legend.Select

    Selection.Delete

    ActiveChart.SetElement (msoElementChartTitleAboveChart)

    ActiveChart.ChartTitle.Text = "% of Time"

    ActiveChart.Axes(xlValue).Select

    Selection.TickLabels.NumberFormat = "0%"

    ActiveChart.SetElement (msoElementDataLabelOutSideEnd)

Open in new window

0
Comment
Question by:Escanaba
  • 4
  • 2
6 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 24749651
try adding
    ActiveChart.ChartArea.Left = 150
    ActiveChart.ChartArea.Width = 200

change parameters according to your needs.

Thomas
0
 
LVL 1

Author Comment

by:Escanaba
ID: 24749818
Thanks, Thomas
How do I get the chart to move down?  
0
 
LVL 39

Expert Comment

by:nutsch
ID: 24749822
ActiveChart.ChartArea.Top= 150
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 39

Expert Comment

by:nutsch
ID: 24749827
you also have .height available
0
 
LVL 1

Author Closing Comment

by:Escanaba
ID: 31598549
Thank you Thomas!
0
 
LVL 39

Expert Comment

by:nutsch
ID: 24749924
You're welcome, glad to help.

Thomas
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now