I am using the following code to position a plot area within a chart so that the X axis values line up with a table that I have underneath the chart
GraphColCount = 36 - Number of columns which I want the chart to be spread over
I can't understand why the 'Offset' of 15 & 18 don't work as they don't seem to set the bottom of the chart area to 18 rows below E7 and the same with the plot area.
Thanks
Code:
Sub CoverRangeWithAChart()
Dim rngChart As Range
Dim rngPlot As Range
Dim objChart As ChartObject
Dim objPlot As PlotArea
Set objChart = ActiveSheet.ChartObjects("Chart 1")
Set objPlot = objChart.Chart.PlotArea
Set rngChart = ActiveSheet.Range(Range("D7"), Range("D7").Offset(18, Range("GraphColCount") + 2))
objChart.Height = rngChart.Height
objChart.Width = rngChart.Width
objChart.Top = rngChart.Top
objChart.Left = rngChart.Left
Set rngPlot = ActiveSheet.Range(Range("E8"), Range("E8").Offset(15, Range("GraphColCount")))
objPlot.Height = rngPlot.Height
objPlot.Width = rngPlot.Width
objPlot.Top = rngPlot.Top
objPlot.Left = rngPlot.Left
End Sub
I can't understand why the 'Offset' of 15 & 18 don't work as they don't seem to set the bottom of the chart area to 18 rows below E7 and the same with the plot area.
Thanks