Hi,

I am using a class module produced by others that performs some numerical task. It has an example spreadsheet file so I follow it closely by matching all the input data types. However when trying to run my own code I encounter the error

Runtime error 458 : variable uses an automation type not supported in visual basic

on the line

fvec = Application.Run(FunctionName_, x, IndependentVariables_)

The whole function in which the crash takes place is

Private Sub LevenbergCostFunction(m As Single, n As Single, x As Variant, _
              ByRef fvec As Variant, ByRef iflag As Single)
  fvec = Application.Run(FunctionName_, x, IndependentVariables_)
  Dim i As Single
  For i = 1 To m
    fvec(i) = fvec(i) - ObservedVariables_(i)
  Next i
End Sub
I tried to debug it and the code runs without any issue up to the very last line of FunctionName_, which is a public function I defined in another module. What could possibly cause the problem? Thanks!