0

I created a user defined function. I'm trying to call it in my macro.

When the code reaches the line with my function, I get a Run-time error

'438': Object doesnt support this property or method?

Function SMM(incentivebeta As Double, agebeta As Double, intercept As Double, incentive As Double, age As Double) As Double

    SMM = 1 / (1 + Exp(-(intercept + incentivebeta * incentive + agebeta * age)))

End Function

Private Sub btnSimulate_Click()
    Dim counter As Long
            For counter = 1 To 360
                ws.Range("start").Offset(counter, 7).Value = WorksheetFunction.SMM(1, 2, 3, 4, 5)
2
  • What is the name of the code module which holds SMM? Commented Dec 6, 2018 at 18:38
  • its named "module2" Commented Dec 6, 2018 at 18:39

2 Answers 2

2

The object which "doesn't support this property or method" is Worksheet Function and the method it doesn't support is SMM. You have defined that function, but that doesn't mean that the function you have defined is now a worksheet function. Just use SMM rather than WorksheetFunction.SMM.

Also, as Gary's Student points out, you will get an unrelated error if ws isn't properly set.

Sign up to request clarification or add additional context in comments.

1 Comment

@financedude Glad I could help. If it solves the problem, you could always mark the answer as accepted (via the check mark next to the answer)
1

You have neither Dim'ed nor Set the worksheet variant ws.

(there may be other errors in your code.)

1 Comment

That particular error would give an "object required" message. Assuming OP doesn't have ws as a global variable, the VBA interpreter encounters the "object doesn't support this method error" when evaluating the right hand side before it gets to the problem on the left hand side of the offending line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.