UDF: More than one input type?

C

Charlotte E.

Hi,

If you look at the ordinary =SUM() function, this takes two types of
input: Numbers and ranges.

I.e., you can either write

=SUM(A1:C3) or =SUM(1,2,3)

I would like to create an UDF which accepts the same, but how to define
the input type???

If I do this:

Function UDF(ValueRange as Range)

....it will only accept range as input, and not numbers???

Help appreciated, please?


CE
 
A

Auric__

Charlotte said:
If you look at the ordinary =SUM() function, this takes two types of
input: Numbers and ranges.

I.e., you can either write

=SUM(A1:C3) or =SUM(1,2,3)

I would like to create an UDF which accepts the same, but how to define
the input type???

If I do this:

Function UDF(ValueRange as Range)

...it will only accept range as input, and not numbers???

Help appreciated, please?

ParamArray:
Function foo(ParamArray x() As Variant)

The ParamArray variable must be a Variant array, there can only be one
ParamArray, and it must be the last arg. Check the type of each member of x()
with VarType to see what you're dealing with.
 
G

GS

Adding to Auric's suggestion...

Function UDFname(Rng As Range, Nums as Variant, Text As String)

...and so on for as many inputs as you want/need for the task.
 
G

GS

Charlotte E. laid this down on his screen :
How to get Microsoft to trash those ¤%%#¤¤%#¤% ribbons, and go back to menus
and toolbars?!?


:)

You do know that J-Walk has a macro available that puts all the old
menus on the Addins tab so you have both, ..right?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top