我正在尝试在Excel VBA(2007)中调用一个函数,但是在调用时出现了语法错误。我有一个名为ImportSets的数据结构数组,其中包含工作表和字符串,并且正在尝试将该数组中项目的成员传递给一个名为Import的函数。
The calling code looks like this:
For n = 1 To 7
Debug.Print ("Destsheet: " & ImportSets(n).DestSheet.name)
Debug.Print ("Sourcesheet: " & ImportSets(n).SourceSheet.name)
Debug.Print ("Sourcecolumn: " & ImportSets(n).SourceColumn)
Import(CostAnalysisWorksheet.Sheets("Reimbursements"), ImportSets(n).DestSheet, ImportSets(n).SourceSheet, ImportSets(n).SourceColumn)
Next n
All of the Debug.Print statements return meaningful and correct strings, and check for the existence of "Reimbursements" returns true. The method call is on one line. Here is the ImportSet object code:
Public Type ImportSet
DestSheet As Worksheet
SourceSheet As Worksheet
SourceColumn As String
...other code...
End Type
The function body looks like this:
Function Import(ByRef ReimbursementSheet As Worksheet, ByRef DestSheet As Worksheet, ByRef ImportSheet As Worksheet, ByRef ImportSheetPriceColumn As String) As String
....code here .....
End Function
I am getting a red-highlighted syntax error on the function call (in the first snippet). I am probably missing something stupid. What is it?