ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UDF help (https://www.excelbanter.com/excel-programming/301506-udf-help.html)

Salman[_2_]

UDF help
 
I need to use the address of a cell where I enter a UDF in
the UDF itself. How can I do that?

So the UDF code would say something like:

take column number of cell where function is entered
return the number of columns between function and column D

Thanks.

Chip Pearson

UDF help
 
Salman,

Application.Caller will return a Range reference to the cell
which called the function.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Salman" wrote in message
...
I need to use the address of a cell where I enter a UDF in
the UDF itself. How can I do that?

So the UDF code would say something like:

take column number of cell where function is entered
return the number of columns between function and column D

Thanks.




david mcritchie

UDF help
 
Hi Salman,

A user defined function does not know the address where you
enter the function, you would have to include that as a parameter.

You can use a function in another macro that has absolution no
connection with any cell address.
i.e. convert_to_cubic_yards(500)

Can you use a worksheet function

H44: =COLUMN(H44) - COLUMN(D1)
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Salman" wrote in message ...
I need to use the address of a cell where I enter a UDF in
the UDF itself. How can I do that?

So the UDF code would say something like:

take column number of cell where function is entered
return the number of columns between function and column D

Thanks.




Tom Ogilvy

UDF help
 
in a UDF

Dim rng as Range
set rng = Applition.Caller

will set rng to the cell containing the UDF

--
Regards,
Tom Ogilvy

"Salman" wrote in message
...
I need to use the address of a cell where I enter a UDF in
the UDF itself. How can I do that?

So the UDF code would say something like:

take column number of cell where function is entered
return the number of columns between function and column D

Thanks.




david mcritchie

UDF help
 
application.caller it is, now I've got to do 5 good replies to
make up for my mistake.

David




All times are GMT +1. The time now is 12:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com