i have function:
Function importCSV(fileName As Variant) As Boolean
' some code
' no importCSV = TRUE
end Function
i call this function
importCSV (fileName As Variant)
every do OK, bud when a modific function.
Function importCSV(fileName As Variant, linkToHeader As Boolean) As Boolean
' some code
' no importCSV = TRUE
end Function
i cant call function like this
importCSV (fileName As Variant, TRUE)
VBA detect syntax error and a must call
a = importCSV(fileName As Variant, TRUE)
Why?
You call a Function procedure by using the function name, followed by the argument list in parentheses, in an expression.
A sub performs a task but does not return a value. A function returns a value of the tasks performed. Subs can be recalled from anywhere in the program and in multiple types.
To call a Sub procedure from another procedure, type the name of the procedure and include values for any required arguments. The Call statement is not required, but if you use it, you must enclose any arguments in parentheses.
Sub procedures DO NOT Return a value while functions may or may not return a value. Sub procedures CAN be called without a call keyword. Sub procedures are always enclosed within Sub and End Sub statements.
To avoid assigning the return value to any variable you can use call
keyword
call importCSV(fileName As Variant, TRUE)
Additionally you can call the function this way:
importCSV fileName:="File name", linkToHeader:=TRUE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With