Microsoft Office Development and Consultancy
 Home|

Excel

|VBA|C#|Finance|Tools|Newsletter|Feedback|Contact 
 Excel > Charts > VBA Code > Resizing< Previous | Next > 


 

Resizing

 
 

This works when any part of the chart is selcted

 
 
1
2
3
4
5
6
7
8
Sub Positioning()
   With ActiveChart.Parent
      .Height = 200
      .Width = 200
      .Top = 100
      .Left = 100
   End With
End Sub
   


 

Aligning and Sizing

 
 

A ChartObject class has standard positional and sizing properties.

 
 

The following code resizes all ChartObjects on Sheet1 so they match the dimensions of the ChartObject named Chart 1

 
 

It also arranges the ChartObjects so they appear on after the other along the left of the worksheet.

 

 
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Sub ResizeArrange()
   With ActiveSheet.ChartObjects("Chart 1")
      W = .Width
      H = .Height
   End With
   TopPos = 0
   For Each objChart In ActiveSheet.ChartObjects
      With objChart
         .Width = W
         .Height = H
         .Left = 0
         .Top = TopPos
      End With
      TopPos = TopPos + H
   Next objChart
End Sub
   




 © Better Solutions Limited 10-May-2013< Previous | Top | Next >