0

My code is as follows:

Function my_if() As Boolean
    my_if = Application.WorksheetFunction.If(True, True, False)
End Function

But I am getting #VALUE as a result. Why is that?

2

1 Answer 1

1

If isn't one of the functions in the WorksheetFunction object. Rather than writing your own my_if function, just use the built-in VBA function IIF instead. Or, you could do:

Function my_if() As Boolean
    my_if = IIf(True, True, False)
End Function
Sign up to request clarification or add additional context in comments.

Comments

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.