以下代码在Object doesn't support this property or method
HelperFunctions.updatecontractlist (PC)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim PCName As String, BU, PC As Variant
If Target.Address = "$B$1" Then
PCName = Target.value
For Each BU In TotalBook.GetBUs
For Each PC In BU.GetPCs
If PC.Name = PCName Then HelperFunctions.updatecontractlist (PC)
Next PC, BU
End If
End Sub
其中updatecontractlist
是:
Public Sub updatecontractlist(PC As Variant)
whatever
End Sub
和PC
是自定义对象,在代码的许多其他部分都能正常工作,我可以在Watches
窗口中看到,当错误发生时,它已正确加载。
我错过了什么?
答案 0 :(得分:0)
你应该改变:
If PC.Name = PCName Then HelperFunctions.updatecontractlist (PC)
到
If PC.Name = PCName Then Call HelperFunctions.updatecontractlist (PC)
或
If PC.Name = PCName Then HelperFunctions.updatecontractlist PC