Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default UDF: More than one input type?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default UDF: More than one input type?

Charlotte E. wrote:

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.

--
Don't any of your street demons have real grown-up names?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default UDF: More than one input type?

That was quick :-)

Thanks...


CE



Den 31.01.2012 08:53, Auric__ skrev:
Charlotte E. wrote:

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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default UDF: More than one input type?

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.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default UDF: More than one input type?

Charlotte E. wrote:

That was quick :-)

Thanks...


Easy answers are fast answers. ;-) Now ask a hard one.

--
- Hercules. Why does that name ring a bell?
- I don't know. Um, maybe we owe him money?


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default UDF: More than one input type?


Now ask a hard one.


How to get Microsoft to trash those ¤%%#¤¤%#¤% ribbons, and go back to
menus and toolbars?!?


:-)


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default UDF: More than one input type?

Charlotte E. wrote:

Now ask a hard one.


How to get Microsoft to trash those ¤%%#¤¤%#¤% ribbons, and go back to
menus and toolbars?!?


I said "hard", not "impossible".

--
Give the laws of physics time to cry alone in the corner.
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default UDF: More than one input type?

Charlotte E. laid this down on his screen :
Now ask a hard one.


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?

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I can't input anything I type on Excel. What can I do? Nothing p. nakalkn Excel Worksheet Functions 2 April 19th 12 12:17 AM
error 13 type mismatch input box cluckers Excel Discussion (Misc queries) 1 October 28th 09 07:01 PM
Input Box - Type mismatch Tendresse Excel Programming 2 January 14th 08 07:07 AM
Type mismatch using rnge as Range with Type 8 Input Box STEVE BELL Excel Programming 11 December 3rd 05 05:02 AM
Input box Type:= 8 not working STEVE BELL Excel Programming 6 October 14th 05 12:50 AM


All times are GMT +1. The time now is 05:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"