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

M

Michelle

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
 
J

Jacob Skaria

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
 
P

ProfessionalExcel.com

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
 
M

Michelle

Thank you, that is exactly what I needed.

M

ProfessionalExcel.com said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top