Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 26th, 2008, 12:21 PM
Registered User
 
Join Date: Feb 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default moving graph using macro

I have added a macro that will collect data and add a graph to my worksheet. Because users will be able to run this macro at any time and repeat the action indefinitely, the chart's name is always changing, e.g. "Chart 23", "Chart 24". After the chart is built I want to move the chart within the worksheet and resize it.

When I record the macro the code is:
ActiveSheet.Shapes("Chart 48").IncrementLeft -212.25
ActiveSheet.Shapes("Chart 48").ScaleWidth 1.52, msoFalse, msoScaleFromTopLeft

I have set a variable to capture the chart's name and it does so successfully (chartname1 = ActiveChart.Name). When I try to insert this into the code, however, it doesn't work.

ActiveSheet.Shapes(chartname1).IncrementLeft -212.25
ActiveSheet.Shapes(chartname1).ScaleWidth 1.52, msoFalse, msoScaleFromTopLeft

The debug says it can't find the object.

Any ideas on how to write this w/o a static chart name?



 
Old April 29th, 2008, 07:40 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 221
Thanks: 0
Thanked 0 Times in 0 Posts
Default

or you can try like this...

Dim i As Integer
i = Charts.Count
Charts(i - 1).Select
With Selection
    .Width
    .Height
    .Left
    .Top
End With

hope this helps.

With Regards,
Raghavendra Mudugal





Similar Threads
Thread Thread Starter Forum Replies Last Post
calling to xlam macro from macro inside xlsb SteveB Excel VBA 0 June 30th, 2008 06:43 PM
graph pab006 Classic ASP Basics 5 July 26th, 2004 10:06 AM
line graph pab006 Classic ASP Basics 4 July 22nd, 2004 09:09 AM
graph pab006 Classic ASP Basics 1 April 30th, 2004 10:08 PM
Graph Customization hosefo81 PHP How-To 3 November 10th, 2003 03:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.