Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel UDF implicit range argument

I have a UDF that works fine and have distributed it to students on an add-in.
It is of the form fun(one as variant, two as variant) as variant
Now I find that some students do a very clever thing. They are working on
financial tables and name the rows with names like sales, cost, and profit.
Then, to calculate profit they simply enter =sales - cost. Copy the formula
to the right to the other columns and it looks the same, but it actually
grabs the right values of sales and cost in each column. I don't see this
documented, but type sales in any column and your will get the figure out of
the sales row for that column.
My problem is that my UDF will not accept this kind of argument. The work
around is simply to write FUN( rate, 0+sales), forcing Excel to convert the
sales reference to a specific number before calling the function.
Is there a way to avoid this work around? And, what is the name of this
strange referencing method my students are using?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default Excel UDF implicit range argument

Named ranges are quite normal in Excel - plenty of info on the web and in
Help.
Eg:
http://www.contextures.com/xlNames01.html
http://www.exceltip.com/exceltips.ph...category&ID=24

What does the rest of your UDF look like ? - that might make a difference in
how it would work with named ranges as inputs...

Tim


"Teach1001" wrote in message
...
I have a UDF that works fine and have distributed it to students on an
add-in.
It is of the form fun(one as variant, two as variant) as variant
Now I find that some students do a very clever thing. They are working on
financial tables and name the rows with names like sales, cost, and
profit.
Then, to calculate profit they simply enter =sales - cost. Copy the
formula
to the right to the other columns and it looks the same, but it actually
grabs the right values of sales and cost in each column. I don't see this
documented, but type sales in any column and your will get the figure out
of
the sales row for that column.
My problem is that my UDF will not accept this kind of argument. The work
around is simply to write FUN( rate, 0+sales), forcing Excel to convert
the
sales reference to a specific number before calling the function.
Is there a way to avoid this work around? And, what is the name of this
strange referencing method my students are using?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default Excel UDF implicit range argument

Hi Tim,

The reference method is called Implicit Intersection. Be careful, it works
correctly only if the function requires a one cell argument. You can't use
it for the MAX function, for example.

Alas, Excel 5 was the last version where implicit intersection worked for
UDFs.

The three workarounds I know a
- the one you describe (any arithmetic will do)
- explicit intersection using the intersection operator, which is the space
character. Then you would write something like =FUN(rate,sales 1:1). Of
course the reference to the row will adjust automatically when you copy or
drag the formula.
This method works elegantly if you use the R1C1 reference style; the formula
then would be =FUN(rate,sales R), where R stands for "this row". Similarly,
=FUN(rate, sales R[-1]) would mean the row above, very handy for financial
projections.
- wrap the VBA UDF in an Excel4 (XLM, (not XML)) function. Implicit
intersection works fine for XLM functions, if you define the argument as
being just one cell.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel



"Tim Williams" wrote in message
...
Named ranges are quite normal in Excel - plenty of info on the web and in
Help.
Eg:
http://www.contextures.com/xlNames01.html
http://www.exceltip.com/exceltips.ph...category&ID=24

What does the rest of your UDF look like ? - that might make a difference
in how it would work with named ranges as inputs...

Tim


"Teach1001" wrote in message
...
I have a UDF that works fine and have distributed it to students on an
add-in.
It is of the form fun(one as variant, two as variant) as variant
Now I find that some students do a very clever thing. They are working on
financial tables and name the rows with names like sales, cost, and
profit.
Then, to calculate profit they simply enter =sales - cost. Copy the
formula
to the right to the other columns and it looks the same, but it actually
grabs the right values of sales and cost in each column. I don't see this
documented, but type sales in any column and your will get the figure out
of
the sales row for that column.
My problem is that my UDF will not accept this kind of argument. The work
around is simply to write FUN( rate, 0+sales), forcing Excel to convert
the
sales reference to a specific number before calling the function.
Is there a way to avoid this work around? And, what is the name of this
strange referencing method my students are using?




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
implicit file reference Tuee Excel Programming 4 February 10th 06 02:55 PM
Possible to chart data for dates implicit within a range? Nechama Charts and Charting in Excel 1 September 1st 05 10:11 PM
implicit activation jgreif Excel Programming 0 May 26th 05 01:59 AM
Function (array argument, range argument, string argument) vba Witek[_2_] Excel Programming 3 April 24th 05 03:12 PM
How to pass an Excel range as an argument to a SQL Server stored Procedure Belinda Excel Programming 7 April 8th 04 11:24 AM


All times are GMT +1. The time now is 11:39 AM.

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"