子例程中的语法错误 'Test'
Syntax error in subroutine 'Test'
我在VBA中有以下子函数:
Sub test()
index_match_array(Range("D5").Value,Range("BZ:BZ").DataSeries,"Hardware",1,2)
End Sub
这将调用启动的函数:
Option Explicit
Function index_match_array(loookup As String, table_array As Range, criteria_search As String, criteria_line_add As Integer, return_line_add As Integer) As String()
Dim lookup_array() As String
Dim result_array() As String
...
...
index_match_array = result_array
End Function
编译时出现错误信息:
Compile error:
Syntax error
我怀疑这与第二个参数有关,范围一,但我不确定?
' 数据系列 return 类型为 Variant ,将 table_array 更改为 Variant
' 函数在数组中,将 Function index_match_array 更改为 String
Option Explicit
Sub test()
Dim sString(10) As String
sString(1) = index_match_array(Range("D5").Value, Range("BZ:BZ").DataSeries, "Hardware", 1, 2)
End Sub
Function index_match_array(loookup As String, table_array As Variant, criteria_search As String, criteria_line_add As Integer, return_line_add As Integer) As String
Dim lookup_array(10) As String
Dim result_array(10) As String
result_array(1) = "Test Value"
index_match_array = result_array(1)
End Function
我在VBA中有以下子函数:
Sub test()
index_match_array(Range("D5").Value,Range("BZ:BZ").DataSeries,"Hardware",1,2)
End Sub
这将调用启动的函数:
Option Explicit
Function index_match_array(loookup As String, table_array As Range, criteria_search As String, criteria_line_add As Integer, return_line_add As Integer) As String()
Dim lookup_array() As String
Dim result_array() As String
...
...
index_match_array = result_array
End Function
编译时出现错误信息:
Compile error: Syntax error
我怀疑这与第二个参数有关,范围一,但我不确定?
' 数据系列 return 类型为 Variant ,将 table_array 更改为 Variant ' 函数在数组中,将 Function index_match_array 更改为 String
Option Explicit
Sub test()
Dim sString(10) As String
sString(1) = index_match_array(Range("D5").Value, Range("BZ:BZ").DataSeries, "Hardware", 1, 2)
End Sub
Function index_match_array(loookup As String, table_array As Variant, criteria_search As String, criteria_line_add As Integer, return_line_add As Integer) As String
Dim lookup_array(10) As String
Dim result_array(10) As String
result_array(1) = "Test Value"
index_match_array = result_array(1)
End Function