Sub SizePies()
'
' Resize pie charts plot area according to a
'
Dim sngNormalSize As Single
Dim objCht As ChartObject
Dim rngSizes As Range
Dim intIndex As Integer
Dim sngTop As Single
Dim sngWidth As Single
' size proportions of pies
Set rngSizes = ActiveSheet.Range("B9:E9")
Set objCht = ActiveSheet.ChartObjects(1)
' Using first chart as point of reference
sngNormalSize = objCht.Chart.PlotArea.Width
sngTop = objCht.Chart.PlotArea.Top
' go thru and resize each pie
For Each objCht In ActiveSheet.ChartObjects
With objCht.Chart
intIndex = intIndex + 1
sngWidth = sngNormalSize * rngSizes.Cells(1, intIndex)
If sngWidth > 10 Then
.PlotArea.Width = sngWidth
.PlotArea.Left = (.ChartArea.Width - .PlotArea.Width) / 2
.PlotArea.Top = sngTop + ((.ChartArea.Height - sngTop) - .PlotArea.Height) / 2
End If
End With
Next
End Sub
|