Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help fixing code to size plot area of chart 3

Status
Not open for further replies.

chilly442

Technical User
Jun 25, 2008
151
US
Upon opening my excel spreadsheet, I want to have all the charts in a worksheet look the same. I can get the chart to size but not the plot area. Here is what I have so far:

Sub testchartsize()
Dim iChtIx As Long, iChtCt As Long

Sheets("Figs").Activate

iChtCt = ActiveSheet.ChartObjects.Count

For iChtIx = 1 To iChtCt

With ActiveChart
.PlotArea.Height = 400
.PlotArea.Width = 600

With ActiveSheet.ChartObjects(iChtIx)
.Height = 430
.Width = 660

End With
End With
Next
End Sub

Any help is worth a star!!

Thanks in advance.
Chilly442
 
Maybe something like;

Sub testchartsize2()

Dim cht As ChartObject

For Each cht In Sheets("sheet1").ChartObjects
cht.Height = 500
cht.Width = 500
cht.Activate
With ActiveChart.PlotArea
.Height = 350
.Width = 350
End With
Next

End Sub
 
That worked perfect. I just wasn't sure how to call the chart, and the plot area.

Thank you very much!!!

Chilly442
 
Are you sure you have to activate the chart ?
For Each cht In Sheets("sheet1").ChartObjects
cht.Height = 500
cht.Width = 500
With cht.PlotArea
.Height = 350
.Width = 350
End With
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV - Odd but it seems like it! Your code gives me an Error 438 Object does not support ... on the line

With cht.PlotArea

Intellisense does not list .PlotArea for cht but does for ActiveChart.
 
OOps, sorry for the typo:
For Each cht In Sheets("sheet1").ChartObjects
cht.Height = 500
cht.Width = 500
With cht[!].Chart[/!].PlotArea
.Height = 350
.Width = 350
End With
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top