View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Myers Bob Myers is offline
external usenet poster
 
Posts: 28
Default Passed Arguments to a UDF

I have a problem passing arguments to a UDF. I believe it is a specific
problem since I've passed a lot of arguments to a lot of other UDF's in the
past. I'm working with Excel 2003 on Vista.

The Workbook looks like:

... F G
R S
14 [F14] [G14 <Range
R14] [S14]

F14 has a formula that produces an Integer as a function of what's in the
Range.
G14:R14 is mostly integers, but with a few alphas and nulls.
S14 has a formula containing the UDF Action(F14, G14:R14).

The UDF takes the form:

Function Action(X As Integer, Rrrr As Range) As Integer
...
Stuff
...
End Function

My problem is the only value I can get out of X is 0 (zero), regardless of
what's in F14.
I've tried ByVal X and the default, ByRef X. Still 0.
I've tried putting an Integer in B3 and passing B3 instead of F14. Still 0.
Since I'm able to pick every cell out of Range Rrrr in the UDF, I've tried
extending Rrrr to F14:R14 (changed
the passed arguments accordingly). Regardless of what's in the first
cell of the Rrrr, all I can still get is a 0.

If I change the Call to Action(3, G14:R14), the 3 comes through for the
value of X.

Any ideas, suggestions?

Respectfully submitted,
Bob Myers