#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default UDF help

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

David


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



All times are GMT +1. The time now is 01:28 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"