ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing plot area under macro (https://www.excelbanter.com/excel-programming/298608-changing-plot-area-under-macro.html)

Don Wiss

Changing plot area under macro
 
When my chart is inactive I clear the data, and I also have to clear the
title. Setting the title to a empty string didn't work, so I am using this
code (though I would prefer to not have to select or activate it):

Sheets("Graphs").Select
ActiveSheet.ChartObjects(1).Activate
ActiveChart.ChartArea.Select
ActiveChart.HasTitle = False

But then when I recreate the chart I find that Excel has gone back to the
absurdly large font size of 22. So I change it to 14. But then I find that
Excel has pushed my plot area down to accomodate the large font. But I
haven't been able to increase the plot area under macro control. This is
the code I'm using to create the chart:

With Worksheets("Graphs").ChartObjects(1).Chart
.SeriesCollection(1).XValues = "=Graphs!R12C17:R" & NewLastRow & "C17"
.SeriesCollection(1).Values = "=Graphs!R12C18:R" & NewLastRow & "C18"
.HasTitle = True
.ChartTitle.Font.Size = 14
.ChartTitle.Text = Range("GraphTitle").Value
If Range("CDFflag").Value Then
.Axes(xlValue).MaximumScale = 1
Else
.Axes(xlValue).MaximumScaleIsAuto = True
End If
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = Res(1)
If Res(2) = 1 Then
.Axes(xlCategory).TickLabels.NumberFormat = "0.0"
Else
.Axes(xlCategory).TickLabels.NumberFormat = "0"
End If
End With

Then how do I add this functionality to the above?

ActiveChart.ChartArea.Select
ActiveChart.PlotArea.Select
Selection.Top = 28
Selection.Height = 206

Thanks, Don <donwiss at panix.com.


All times are GMT +1. The time now is 01:38 AM.

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