PC Review


Reply
Thread Tools Rate Thread

Creating a UDF to convert ADDRESS function output as a reference

 
 
exceluser
Guest
Posts: n/a
 
      14th Feb 2011
Is it possible to create a UDF that converts the output returned by
the ADDRESS function as a reference and not as text ?




Exceluser
 
Reply With Quote
 
 
 
 
exceluser
Guest
Posts: n/a
 
      15th Feb 2011
Ron,

Thanks for the quick response.

I was trying to avoid use of the INDIRECT function since it's
volatile and would cause excessive calculation time.

Would it be a problem to change the UDF from "Application.Volatile"
to "Application.Volatile (False)" ?



Exceluser
 
Reply With Quote
 
joeu2004
Guest
Posts: n/a
 
      15th Feb 2011
On Feb 15, 9:54*am, Ron Rosenfeld <r...@nospam.net> wrote:
> On Tue, 15 Feb 2011 09:45:14 -0800 (PST), exceluser <ifmcqy7aias...@yahoo..com> wrote:
> > Would it be a problem to change the UDF from
> > "Application.Volatile"
> > to "Application.Volatile (False)" ?


(Or simply eliminated the statement altogether, which has the same
effect.)

Ron wrote:

> You can change it to be non-volatile so long as you
> don't mind the fact that there will be no automatic
> recalculation when you change the cell referred to.


Can you provide a concrete example that demonstrates that problem?
Also, please specify the Excel and VBA versions.

In my experience (XL2003 SP3, VBA 6.5), as long as the UDF itself
accesses the parameter, it will create an Excel dependency, so
Application.Volatile is not necessary.

Example:
B1:B3 contains 1, 2, 3
A1 contains 1
A2 contains 2
A3: =ADDRESS(A1,A2)
A4: =myIndirect(A3)

Initially, A3 returns $B$1, and A4 returns 1, the contents of B1.

After changing A1 to 2, A3 returns $B$2, and A4 returns 2, the
contents of B2.

UDF....

Function myIndirect(s As String)
myIndirect = Range(s).Value2
End Function

-----

PS.... I also tried myIndirect defined as Ron did (below), which
makes it useful in other contexts as well, for example the following
nonsensical formula just to demonstrate the difference between range
and value result:

=VLOOKUP(myIndirect(A3),myIndirect(A3),1)

This form, as well, tracked changes in A1 without the need for
Application.Volatile.

UDF....

Function myIndirect(s As String) As Range
Set myIndirect = Range(s)
End Function
 
Reply With Quote
 
joeu2004
Guest
Posts: n/a
 
      16th Feb 2011
On Feb 15, 6:50*pm, Ron Rosenfeld <r...@nospam.net> wrote:
> By the way, in your version of Excel, did the example I
> provided initially, in my response to the OP, track the
> changes in A1?


Right, your original example was sufficient. I wasn't paying
attention. My bad!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a lookup function to output a cell address adambush4242@hotmail.com Microsoft Excel Misc 3 2nd Jul 2008 09:13 PM
Convert String to Function Reference ViestaWu Microsoft Excel Worksheet Functions 1 27th Nov 2007 06:58 AM
Use function output as a cell reference =?Utf-8?B?TmlnZWw=?= Microsoft Excel Worksheet Functions 2 8th Feb 2007 02:14 PM
Function/ formula to output a cell reference =?Utf-8?B?Q3JlYXRvcg==?= Microsoft Excel Worksheet Functions 19 17th Feb 2006 06:39 PM
How can I convert text to reference ? Ex: ISNUMBER(ADDRESS(6;10;2. =?Utf-8?B?RmVybmFuZG9NZW5kZXM=?= Microsoft Excel Misc 1 28th Jan 2005 06:54 PM


Features
 

Advertising
 

Newsgroups
 


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