PDA

View Full Version : Set Chart size using VBA



LalitPandey87
10-18-2011, 01:32 PM
Hi All,

I need a function which change the height and width of all the charts in the active sheet.

Thanx in Adavance.

Admin
10-18-2011, 02:55 PM
Hi,


Sub FixChartSize(ByVal cHeight As Single, cWidth As Single, Optional ByRef Chart_Object As ChartObject, Optional ByRef Sht As Worksheet)

Dim i As Long
Dim c As Long

If Sht Is Nothing Then Set Sht = ActiveSheet

If Chart_Object Is Nothing Then
c = Sht.ChartObjects.Count
If c Then
For i = 1 To c
With Sht.ChartObjects(i)
.Height = cHeight
.Width = cWidth
End With
Next
End If
Else
With Chart_Object
.Height = cHeight
.Width = cWidth
End With
End If

End Sub

and call like

FixChartSize 350, 700

Rasm
10-28-2011, 07:00 AM
Mohan
You should check the chart sizer under cool code - you will luv it. You simply click on a chart - it then maximizes - you click again it minimizes.

LalitPandey87
11-08-2011, 08:54 AM
Thanx for this useful function.
Working!
:cool: