Excel 找不到数据成员的成员VBA

Excel 找不到数据成员的成员VBA,excel,vba,Excel,Vba,正如标题所说,代码将找不到ActiveChart,即使它选择它之前的行也是如此。我怎样才能修好它 Sub makeChart(myArr As Variant, title As String) Dim cht As Chart Dim sht As Worksheet Set sht1 = Sheets("Action Register") sht1.Shapes.AddChart.Select Set cht = sht.ActiveChart

正如标题所说,代码将找不到
ActiveChart
,即使它选择它之前的行也是如此。我怎样才能修好它

Sub makeChart(myArr As Variant, title As String)
    Dim cht As Chart
    Dim sht As Worksheet

    Set sht1 = Sheets("Action Register")
    sht1.Shapes.AddChart.Select

    Set cht = sht.ActiveChart
    With ActiveChart
    .Parent.Top = Range("D20").Top 'Places chart onto specified area
    .Parent.Left = Range("D20").Left
    .Parent.Width = Range("D20:V20").Width
    .Parent.Height = Range("D20:D29").Height

    .ChartType = xlAreaStacked
    .SeriesCollection.NewSeries
    .SeriesCollection(1).Name = "=""Machine"""
    .SeriesCollection(1).XValues = Application.Index(myArr, , 1)
    .SeriesCollection(1).Values = Application.Index(myArr, , 2)
    .SeriesCollection.NewSeries
    .SeriesCollection(2).Name = "=""Handling"""
    .SeriesCollection(2).Values = Application.Index(myArr, , 3)
    .SeriesCollection.NewSeries
    .SeriesCollection(3).Name = "=""Fiber"""
    .SeriesCollection(3).Values = Application.Index(myArr, , 4)
    .SeriesCollection.NewSeries
    .SeriesCollection(4).Name = "=""Process"""
    .SeriesCollection(4).Values = Application.Index(myArr, , 5)
    .SeriesCollection.NewSeries
    .SeriesCollection(5).Name = "=""Other"""
    .SeriesCollection(5).Values = Application.Index(myArr, , 6) 'Legends and writes in values for graph

    .Axes(xlCategory, xlPrimary).HasTitle = True 'Labels
    .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Months"
    .Axes(xlValue, xlPrimary).HasTitle = True
    .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Rate(m)"
    .ChartArea.Font.Size = 20

    End With
End Sub

在顶部的右边,我可以看到这两个错误

Dim sht1 As Sheets <-------- you forgot this (not sht as Worksheet)
Set sht1 = Sheets("Action Register")
sht1.Shapes.AddChart.Select

Set cht = sht.ActiveChart <-------------- you got your naming all wrong here

Dim sht1 As Sheets工作表没有
ActiveChart
属性。只需使用
ActiveChart
应用程序即可。ActiveChart

工作表没有
ActiveChart
属性。只需使用
ActiveChart
应用程序。ActiveChart
dim as工作表和工作表之间的区别是什么?名称(很抱歉,根本不清楚)sht>sht1,并且工作表对象可以包含图表。