2

In my excel sheet my entire column(A) i named it "myRadius" and in "A1" the cell value is 15.25. My entire column(B) i named it "myConstant" and the cell value for "B1" is 5. Then in "C1" i type some formulas which is "=myRadius*myConstant" and the result is 76.25. But when i create a VBA Function(UDF) for cleaner code and type it in "D1" the result is "#VALUE!". Here is my UDF.

Function ComplexCircle(myRad As Variant, myCons As Variant)
ComplexCircle = myRad * myCons
End Function

In "D1" i type "=ComplexCircle(myRadius,myConstant)" Do i missing something? I did try variant/double/range parameter but it doesn't work

6
  • This isn't an answer to specific question but can you not just type in "D1" =ComplexCircle(A1,B1) ? Or what's wrong with good old-fashioned =A1*B1 - why do you use the named ranges?
    – jamheadart
    Commented Oct 3, 2018 at 4:59
  • nope. this is just a simple and shortened formula of my current project. the real formula contains 10parameters of double/integers/string which are not namedrange, just a plain single cell value. The problem with that one is, if i will change the range of my namedrange, the old fashioned way is not applicable in a big project
    – Vincent
    Commented Oct 3, 2018 at 5:02
  • I think you've quite possibly over-simplified your minimal reproducible example, and removed the bug doing so: there's no reason for this code to blow up under the circumstances you're talking about, especially if you tried explicit parameter types. Commented Oct 3, 2018 at 5:15
  • Perhaps the function is not located in a public ("regular") module?
    – ashleedawg
    Commented Oct 3, 2018 at 5:18
  • 1
    also, if you're entering =ComplexCircle(myRadius,myConstant) that implies that you have named ranges called myRadius and myConstant. If this is a question about basic usage of Excel then this may not be the right place for it. See the help center for more information about what's on-topic on this site.
    – ashleedawg
    Commented Oct 3, 2018 at 5:20

0

Your Answer

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

Browse other questions tagged or ask your own question.