我在下面突出显示的行上遇到类型不匹配错误13,但我怀疑我将在所有范围内收到此错误。
Function Xtreme(Window_ID As Range, WIDTH As Range, HEIGHT As Range, xlb As Range, ylb As Range, Coord_Opt As Integer)
Dim iHOT_SURF(100) As Single
Dim iCOLD_SURF(100) As Single
Dim iHOT_NUM As Single
Dim x_L(100) As Single
Dim x_R(100) As Single
Dim x_C(100) As Single
For i = 1 To iHOT_NUM
**x_L(i) = WorksheetFunction.Index(xlb, i)**
这就是我调用函数(测试)的方法:
Sub testmy()
Dim x As Variant
x = Xtreme(Sheets("Groupwise Data").Range("A5:A29"), Sheets("Groupwise Data").Range("B5:B29"), Sheets("Groupwise Data").Range("C5:C29"), Sheets("Groupwise Data").Range("E5:E29"), Sheets("Groupwise Data").Range("F5:F29"), 1)
End Sub
范围包含值或为空(使用IFERROR(Value, "")
)
有人可以告诉我如何让这个功能正常工作吗?
谢谢!
答案 0 :(得分:0)
尝试
x_L(i) = CSng(WorksheetFunction.Index(xlb, i))
或者
x_L(i) = CSng(Application.WorksheetFunction.Index(xlb, i))
让WorksheetFunction返回一个Variant。参考:http://msdn.microsoft.com/en-us/library/office/ff197581.aspx