PC Review


Reply
Thread Tools Rate Thread

Can my UD function know what cell it's in?

 
 
Michelle
Guest
Posts: n/a
 
      14th Aug 2009
I'm writing a User Defined Function and I want to be able to utilise the
address (or Column No/Row No or any other reference to the address) of the
cell that the function is actually in. If I copy it across, obviously each
one will need to refer to a different cell - i.e. the one that each function
is in.

I don't mind if it's code or a built-in function that gives me the result

I'm sure there miust be a way. I just can't get my head round it.

Thanks

Michelle

 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      14th Aug 2009
The argument varRange refers to the cell referred..

Try in any of the cell
=Mytest(A1)

Function MyTest(varRange As Range)
MyTest = varRange.Address
End Function

If this post helps click Yes
---------------
Jacob Skaria


"Michelle" wrote:

> I'm writing a User Defined Function and I want to be able to utilise the
> address (or Column No/Row No or any other reference to the address) of the
> cell that the function is actually in. If I copy it across, obviously each
> one will need to refer to a different cell - i.e. the one that each function
> is in.
>
> I don't mind if it's code or a built-in function that gives me the result
>
> I'm sure there miust be a way. I just can't get my head round it.
>
> Thanks
>
> Michelle
>

 
Reply With Quote
 
ProfessionalExcel.com
Guest
Posts: n/a
 
      14th Aug 2009
Michelle,

Within your User Defined Function, use the following code:

Application.Caller

This is a range object that refers to the range that has called the UDF.


--
----------------------------
Please rate this post if it answers your question.

Thanks,

Chris
http://www.ProfessionalExcel.com


"Michelle" wrote:

> I'm writing a User Defined Function and I want to be able to utilise the
> address (or Column No/Row No or any other reference to the address) of the
> cell that the function is actually in. If I copy it across, obviously each
> one will need to refer to a different cell - i.e. the one that each function
> is in.
>
> I don't mind if it's code or a built-in function that gives me the result
>
> I'm sure there miust be a way. I just can't get my head round it.
>
> Thanks
>
> Michelle
>

 
Reply With Quote
 
Michelle
Guest
Posts: n/a
 
      14th Aug 2009
Thank you, that is exactly what I needed.

M

"ProfessionalExcel.com" <(E-Mail Removed)>
wrote in message news:EA7F8910-BE00-4669-8ADE-(E-Mail Removed)...
> Michelle,
>
> Within your User Defined Function, use the following code:
>
> Application.Caller
>
> This is a range object that refers to the range that has called the UDF.
>
>
> --
> ----------------------------
> Please rate this post if it answers your question.
>
> Thanks,
>
> Chris
> http://www.ProfessionalExcel.com
>
>
> "Michelle" wrote:
>
>> I'm writing a User Defined Function and I want to be able to utilise the
>> address (or Column No/Row No or any other reference to the address) of
>> the
>> cell that the function is actually in. If I copy it across, obviously
>> each
>> one will need to refer to a different cell - i.e. the one that each
>> function
>> is in.
>>
>> I don't mind if it's code or a built-in function that gives me the result
>>
>> I'm sure there miust be a way. I just can't get my head round it.
>>
>> Thanks
>>
>> Michelle
>>


 
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
ISBLANK function not working when cell is blank dut to function re mcmilja Microsoft Excel Misc 8 21st Jun 2008 04:13 PM
Changing a cell color inside a function called by that cell Wayne Erfling Microsoft Excel Programming 8 29th Jan 2007 01:55 AM
A correct IF function doesn't show the function's result in cell =?Utf-8?B?TWljaGFlbA==?= Microsoft Excel Misc 1 10th Apr 2006 09:10 AM
Can function in one cell change value or function in another cell? me Microsoft Excel Worksheet Functions 4 27th Feb 2006 01:04 PM
using the offset function to subtract a cell in b column from cell in a instead of adding mike Microsoft Excel Worksheet Functions 1 18th Oct 2004 08:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:04 AM.