View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Richard Ahlvin Richard Ahlvin is offline
external usenet poster
 
Posts: 3
Default User function argument question

I have a user function that works fine when I supply a cell reference as an
argument. It also works if I supply a named call as the argument. However,
when I supply the name of a range of cells, I get A #Value! error. Built-in
functions (such as SQRT) work O-K. What do I need to do to user functions
to make the arguments behave the same as for built-in functions.

R.Ahlvin

Example:
| A | B | C
--------------------------------
1 |NAME | |
2 | 7 | 7 | 2.645751
3 | 4 | 4 | 2
4 | 8 | #Value | 4

NAME Refers to: =Sheet1!$A$2:$A$4

Formulas:
| A B C
--------------------------------------
1 |NAME
2 | 7 =Fun(A2) =SQRT(A2)
3 | 4 =Fun(A3) =SQRT(A3)
4 | 8 =Fun(NAME) =SQRT(NAME)

Function:

Function FUN( ARG As Variant)
DIM X As Double
X = ARG.Value
FUN = X
End Function