I'm trying to call a function in Excel VBA (2007), and am recieving a syntax error on the call. I have an array of data structures called ImportSets, which contains worksheets and strings, and am trying to pass members of items in that array to a function, called 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?
See Question&Answers more detail:os