types不匹配传递单元格(3,4)作为范围参数
我正在Excel中使用一个以Range作为参数的子类来编写一个小类。 但是,当我尝试使用单元格调用它,我得到types不匹配错误。 (使用范围调用工作正常)
代码摘录:
Dim Com, Gua As Worksheet Set Com = Worksheets(cCom) Set Gua = Worksheets(cGua) Dim myFirm As clsFirm Set myFirm = New clsFirm Call myFirm.Init(Gua.Cells(3, 4)) '<--ERROR HERE Call myFirm.Init(Gua.Range("E3")) ' this line works
这里是子:
Public Sub Init(nameCell As Range) pAddress = nameCell.Address pName = nameCell.Value2 pContract = nameCell.Offset(0, -3).Value2 pAmount = nameCell.Offset(0, 2).Value2 pRate = nameCell.Offset(0, 1).Value2 pStartDate = CDate(nameCell.Offset(0, -2).Value2) pEndDate = CDate(nameCell.Offset(0, -1).Value2) End Sub