-1

我在下面突出显示的行上收到类型不匹配错误 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, "")

有人可以告诉我如何让这个功能正常工作吗?

谢谢!

4

1 回答 1

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

于 2013-06-06T07:38:03.453 回答