Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Select proper charts to resize

I have a spread sheet in excel that has embedded charts. Whenever the
data is changed the size of the chart can change (size). I want to run
a macro that sets the charts back to a set size. Here is my code.

Sub resizechart()
Sheets("Analysis").Select
Dim topCoor As Long, botCoor As Long, _
rgtCoor As Long, lftCoor As Long
With Range("A110")
topCoor = .Top
lftCoor = .Left
End With
With Range("J125")
rgtCoor = .Offset(0, 1).Left
botCoor = .Offset(1, 0).Top
End With
With ActiveSheet.ChartObjects(1)
.Top = topCoor
.Left = lftCoor
.Width = rgtCoor - lftCoor
.Height = botCoor - topCoor
End With

With Range("A126")
topCoor = .Top
lftCoor = .Left
End With
With Range("J140")
rgtCoor = .Offset(0, 1).Left
botCoor = .Offset(1, 0).Top
End With
With ActiveSheet.ChartObjects(2)
.Top = topCoor
.Left = lftCoor
.Width = rgtCoor - lftCoor
.Height = botCoor - topCoor
End With
With Range("A141")
topCoor = .Top
lftCoor = .Left
End With
With Range("F160")
rgtCoor = .Offset(0, 1).Left
botCoor = .Offset(1, 0).Top
End With
With ActiveSheet.ChartObjects(3)
.Top = topCoor
.Left = lftCoor
.Width = rgtCoor - lftCoor
.Height = botCoor - topCoor
End With
With Range("G141")
topCoor = .Top
lftCoor = .Left
End With
With Range("J160")
rgtCoor = .Offset(0, 1).Left
botCoor = .Offset(1, 0).Top
End With
With ActiveSheet.ChartObjects(4)
.Top = topCoor
.Left = lftCoor
.Width = rgtCoor - lftCoor
.Height = botCoor - topCoor
End With
End Sub

This code works to place each chart into the correct location and size
on the spreadsheet. The problem is matching chartObjects(X) to Chart
Name. If I select a chart in Excel and view Chart Window I see the
chart window labeled as [Analysis.xls]Analysis Chart 3. Does anyone
know how to determine ChartObjects(1) is equal to
[Analysis.xls]Analysis Chart 3? or code to select
[Analysis.xls]Analysis Chart 3 for resize?

Thanks in advance for suggestions.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I can't select, move or resize an image in Excel?? Michael Howes Excel Discussion (Misc queries) 3 April 2nd 23 07:40 PM
resize charts ayesha Charts and Charting in Excel 0 October 16th 06 02:59 AM
resize charts to paste into powerpoint/word k2sarah Charts and Charting in Excel 1 February 19th 06 11:15 PM
Pie Charts Resize Automatically - How To Avoid? John Mansfield Charts and Charting in Excel 0 May 11th 05 08:12 PM
Urgent help! how to automatically resize all the charts? crossingmind Excel Worksheet Functions 2 April 28th 05 04:56 PM


All times are GMT +1. The time now is 09:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"