VBA Excel错误“;对象变量或未设置块变量";运行时错误91&;438

VBA Excel错误“;对象变量或未设置块变量";运行时错误91&;438,excel,vba,class,Excel,Vba,Class,我正在尝试使用以下代码绘制一组值 Option Explicit Sub graphs() Dim chart1 As Variables Dim rlong As Single rlong = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row Set chart1 = New Variables With chart1 .range_data = ActiveSheet.Range(Cells(3, 1), Cells(rlong,

我正在尝试使用以下代码绘制一组值

Option Explicit

Sub graphs()
Dim chart1 As Variables
Dim rlong As Single

rlong = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

Set chart1 = New Variables


With chart1
    .range_data = ActiveSheet.Range(Cells(3, 1), Cells(rlong, 1))
    .range_close = ActiveSheet.Range(Cells(3, 2), Cells(rlong, 2))
    .range_ema50 = ActiveSheet.Range(Cells(3, 3), Cells(rlong, 3))
    .range_ema100 = ActiveSheet.Range(Cells(3, 4), Cells(rlong, 4)) 'Object variable or with block variable not set. Error 91
End With

charting (chart1) 'Object doesn't support this property or method. Error 438
End Sub
这里Variables是一个用户定义的类,它包含我要填充的变量

运行时最初在以下行给出一个错误

.range_ema100 = ActiveSheet.Range(Cells(3, 4), Cells(rlong, 4)) 'Object variable or with block variable not set. Error 91
当我删除该行以运行代码时,调用子例程时会出现另一个错误

charting (chart1) 'Object doesn't support this property or method. Error 438

感谢所有支持…感谢您

缺少对象变量所需的
集合
?您是否在
变量
类中设置范围?对于另一个错误,请删除
()
将线图(chart1)更改为“charting chart1”@BigBen,您是对的“Set”会清除错误。谢谢。@Warcupine…谢谢你的澄清。。。。
charting (chart1) 'Object doesn't support this property or method. Error 438