Sheets(appServer & "chart").Select
ActiveChart.ChartTitle.Select
ActiveChart.ChartTitle.Text = appServer
ActiveChart.PlotArea.Select
Selection.Width = 434.944
ActiveChart.Legend.Select
ActiveChart.ChartArea.Select
ActiveChart.Legend.Select
Selection.Left = 466.86
Selection.Top = 62.544
This is my code to shrink the plot area of a chart in order to move the legend over to make room for checkboxes to toggle the display of each series. The program works great until I save and reopen it. When it is reopened the checkboxes end up on top of the legend and I can easily fix that every time I reopen the file, but I would rather just fix the issue in my code.Thanks in advance for any help.
Dim chartRangeStart As Integer
Dim chartRangeEnd As Integer
Dim serverNum As Integer
Dim numOfServers As Integer
Dim topOfCheckbox As Integer
Dim appServerNum As Integer
Dim appServer As String
chartRangeStart = 51
chartRangeEnd = 98
numOfServers = 23
serverNum = 1
topOfCheckbox = 56
appServerNum = 0
appServer = server
Do While serverNum <= numOfServers
ActiveChart.CheckBoxes.Add(4529766, 485607, 685185.75, 685896.75).Select
Selection.Characters.Text = ServerNamesArray(appServerNum)
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 9
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoFalse
With Selection
.Value = xlOff
.LinkedCell = appServer & "!$" & ColumnArray(appServerNum) & "$2"
.Display3DShading = False
End With
Selection.ShapeRange.IncrementLeft 465#
Selection.ShapeRange.IncrementTop topOfCheckbox
Selection.ShapeRange.ScaleWidth 2#, msoFalse, msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 1#, msoFalse, msoScaleFromTopLeft
topOfCheckbox = topOfCheckbox + 13
Loop
This is the code that adds the checkboxes to the chart.