VBA Position Chart in Excel 2010

charts, vba

Solution

To continue on from my comment below the original post, try replacing:

.Height = Range("N2:N14").Height
.Width = Range("N2:T2").Width
.Top = Range("N2").Top
.Left = Range("N2").Left

with:

.Parent.Height = Range("N2:N14").Height
.Parent.Width = Range("N2:T2").Width
.Parent.Top = Range("N2").Top
.Parent.Left = Range("N2").Left

Problem

I am trying to add a chart to a worksheet and then position it according to a certain range of cells. I am using the .top, .left, etc. functions and it keeps giving me an error that my object does not support the method being used. What am I doing wrong?! Here is my code: ``` Sub AddCharts() Range("O1").Select Dim sh As Worksheet Dim chrt As Chart Dim lastrow As Long lastrows = Range("A2").End(xlDown).Row Set sh = ActiveWorkbook.Worksheets("TraceTable") Set chrteit = sh.Shapes.AddChart.Chart With chrteit .ChartType = xlXYScatter .SeriesCollection.NewSeries .SeriesCollection(1).XValues = sh.Range(Cells(2, 6), Cells(lastrows, 6)) .SeriesCollection(1).Values = sh.Range(Cells(2, 7), Cells(lastrows, 7)) .HasTitle = True .ChartTitle.Text = "EIT" .Height = Range("N2:N14").Height .Width = Range("N2:T2").Width .Top = Range("N2").Top .Left = Range("N2").Left End With End Sub ```

Original source

Related problems