If I have an excel function such as:
=my_function(A1:C4)
and I want to call this from VBA like:
Dim t as variant
t = Applic
I haven't try it, but wouldn't
t=myfunction(range)
The simplest syntax is
Application.Run("my_function", [A1:c4])
Your range has to come from a worksheet, so if you define that range first and then pass it to the function in your other workbook (I assume that's what you want to do since you wouldn't use Application.Run otherwise). So the following code will do the trick:
Sub RunFunctionInAnotherWorkbook()
Dim rThisRange as Range
Dim vResult as Variant
Set rThisRange = ActiveSheet.Range("A1:C4")
vResult = Application.Run("'MyOtherWorkbook.xls'!TheModuleName.TheSubName", rThisRange)
End Sub
And the function in the workbook "MyOtherWorkbook.xls":
Function TheSubName(inputRange as Range) as Variant
'Work your magic here
End Function