My VBA Function is not accepting two variables for a basic function. It keeps giving a #VALUE! error.
Function myFunction(x As Integer, y As Integer) As Integer
result = x + y
myFunction = result
End Function
However, it works fine if I simply remove the y variable. For example, this works perfectly:
Function myFunction(x As Integer) As Integer
result = x + x
myFunction = result
End Function
I am using Windows 10 Pro on a Lenovo Yoga.
myFunction(1,2)try puttingcallin front of it so it would beCall myFunction(1,2)- or you can remove the brackets so it'd bemyFunction 1,3ythat you are feeding in. If it looks like a number, are there any other (non-printing) characters in the cell that would cause VBA to interpret it as text? (check by doinglen(y))=myFunction(1;2)*By the way, to alert a commenter that you have posted a response to them, use@commenters_namein your comment)