为什么我在此VBA代码中收到对象所需的错误

时间:2016-01-06 11:03:18

标签: vba

错误似乎发生在for循环的开头,这里是代码

Sub constructContractScurves(contractCollection As Collection)

    Dim xArray() As Variant
    Dim yArray() As Variant
    Dim ans As Boolean
    Dim contract As CContract

    For Each contract In contractCollection
        xArray = constructXarray(contract.numMonths)
        yArray = constructYarray(xArray, contract.numMonths)
        ans = utilityMod.populateSheet(xArray, yArray, "S-Curve-BW", 49, 7)
    Next contract
End Sub

1 个答案:

答案 0 :(得分:0)

感谢您的回复,感谢您。问题是调用此子函数的函数在if语句中具有集合的实例化,因此如果不满足条件,则集合不会成为实例。当我把它从if语句中取出时,代码编译成功。

由于