?
Solved

Excel 2007 VB To Move & Resize Chart

Posted on 2009-06-30
6
Medium Priority
?
662 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

719 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