ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using VBA to get all my charts to be same size (https://www.excelbanter.com/excel-programming/276346-re-using-vba-get-all-my-charts-same-size.html)

Andy Pope

Using VBA to get all my charts to be same size
 
Hi Alan,

I don;t think you can change all the objects at once.
Try something like this to do each chart individually.

Sub Equalise_Size()
Dim objChart As ChartObject

For Each objChart In ActiveSheet.ChartObjects
With objChart.Chart.PlotArea
.Width = 374
.Height = 150
End With
Next
End Sub


Alan wrote:

Hi,

I have the following code in a module, but I cannot get it to work:


Sub Equalise_Size()

With ActiveSheet.ChartObjects

.Activate
ActiveChart.PlotArea.Select
Selection.Width = 374
Selection.Height = 150

End With

End Sub


Can anyone suggest why it doesn't work? Excel just tells me that I have a
run time error 438, and that the "Object doesn't support this property or
method."

However, that cannot be true, since I can get it to work on a single
specified chart with the following main body of code:


ActiveSheet.ChartObjects("Chart 1026").Activate
ActiveChart.PlotArea.Select
Selection.Width = 374
Selection.Height = 150


Any suggestion are most welcome.

Thanks,

Alan.




--

Cheers
Andy

http://www.andypope.info



All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com