Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using a Named Range (formula) in a UDF

I am setting up a workbook which will contain hundreds of
calls to a user defined function. The function requires
some column numbers to work, which I originally obtained
via a Match() call against a header row. However, I am
hoping to avoid making Excel run the match code to get the
same column numbers, for each cell that calls the function
when the sheet is recalculated.

Hence, I thought I could set up a named range which
contains the match formula, and then reference the named
range within the formula to get the column numbers. The
formula takes a range also, and I would not have to worry
about Excel failing to recalculate when needed because the
named range would never change alone.

So far, however, I have found no way to get the number
from the named range/formula without using the evaluate
function on the Value or RefersTo property of the named
range. I believe this completely defeats the purpose,
since it evaluates the code rather than just taking the
result, as would a reference to the range in a cell.

So, is there any way to call a Named Range which is really
a function from within a UDF without evaluating it
separately? Or is there some other way to accomplish what
I am trying to do without either hard-coding the column
numbers or adding arguments to my UDF? Perhaps a regular
function instead of a named range? Basically I just want
to do whatever is most efficient but still readable.

Thanks,
Sean Maguire
email maguires
domain newschool.edu
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default using a Named Range (formula) in a UDF

Hi Sean,

I would just cache the numbers in a module level variant array
Dim vCols as variant ' at module level

then in your UDF something like

if IsEmpty(vCols) then vCols=[NamedRange]

this should evaluate the named range formula the first time the UDF gets
executed but not subsequently



regards
Charles
______________________
Decision Models
FastExcel Version 2 now available.
www.DecisionModels.com/FxlV2WhatsNew.htm

"Sean Maguire" wrote in message
...
I am setting up a workbook which will contain hundreds of
calls to a user defined function. The function requires
some column numbers to work, which I originally obtained
via a Match() call against a header row. However, I am
hoping to avoid making Excel run the match code to get the
same column numbers, for each cell that calls the function
when the sheet is recalculated.

Hence, I thought I could set up a named range which
contains the match formula, and then reference the named
range within the formula to get the column numbers. The
formula takes a range also, and I would not have to worry
about Excel failing to recalculate when needed because the
named range would never change alone.

So far, however, I have found no way to get the number
from the named range/formula without using the evaluate
function on the Value or RefersTo property of the named
range. I believe this completely defeats the purpose,
since it evaluates the code rather than just taking the
result, as would a reference to the range in a cell.

So, is there any way to call a Named Range which is really
a function from within a UDF without evaluating it
separately? Or is there some other way to accomplish what
I am trying to do without either hard-coding the column
numbers or adding arguments to my UDF? Perhaps a regular
function instead of a named range? Basically I just want
to do whatever is most efficient but still readable.

Thanks,
Sean Maguire
email maguires
domain newschool.edu



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
Question on Named range with formula DocBrown Excel Worksheet Functions 2 June 5th 09 01:30 AM
Array as a "named range" - formula ok in cells, but error as "named range" tskogstrom Excel Discussion (Misc queries) 11 December 28th 06 04:44 PM
Formula for named range TUNGANA KURMA RAJU Excel Discussion (Misc queries) 2 July 1st 06 05:41 AM
named range into formula? heymoa Excel Worksheet Functions 4 May 22nd 06 02:05 PM
Count formula within a named range. PW11111 Excel Discussion (Misc queries) 2 July 19th 05 09:29 AM


All times are GMT +1. The time now is 06:34 AM.

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

About Us

"It's about Microsoft Excel"