Solved

Excel 2007 VB To Move & Resize Chart

Posted on 2009-06-30
6
657 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 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

735 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