خرید بک لینک

Vote count: 0

I am trying to create a dynamic chart that will change the data set with time, but I am stuck at the first step which is creating a simple chart with a certain limited number of points.

My x values and Y values are at rows 3 and 5.

The code I am trying to run is to create the chart in the same worksheet I am using:

Sub UpdateChart()

Dim ChtObj As ChartObject

Set ChtObj = ActiveSheet.ChartObjects("Bending Moment along " & ActiveSheet.Name) 'Adjust chart name to your chart

With ChtObj.Chart
    .ChartType = x1XYScatterSmooth
    .SetElement msoElementLegendNone
    .Axes(xlValue).MinimumScale = 0
    .Axes(xlValue).MaximumScale = 5
    .SeriesCollection.NewSeries
    .SeriesCollection(1).Name = "Bending moment"
    .SeriesCollection(1).Values = Range("D3:H3")
    .SeriesCollection(1).XValues = Range("D5:H5")
End With

End Sub

I am getting error run-time 5, invalid procedure call or argument? This happens at the line of: With ChtObj.Chart

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 15 ارديبهشت 1395 ساعت: 3:32

صفحه بندی