Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with UDF


Hello people,

If I have a user-defined function that I use to, say, calculate
cumulative total (I know I don't need VBA for this, it's just a
example). Is there any way I can retrieve the address of the cell wher
the UDF was called? or determine whether it was called by the use
inside the worksheet or by a diferent function?

If the answer to the first question is no, I will have to pass the cel
address explicitly as a parameter of the UDF. Whats the best way o
doing this? The obvious (for me) solution - passing the column and ro
numbers as integers - seems cumbersome. Is it possible to use the A
notation here?

Thanks for any help,

Liosa

--
Liosa
-----------------------------------------------------------------------
Liosan's Profile: http://www.excelforum.com/member.php...fo&userid=2629
View this thread: http://www.excelforum.com/showthread.php?threadid=39639

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Problem with UDF

Liosan

The Application.Caller method gives you the address of the cell from which
VBA was called. See the Help for some caveats though...

To get the address of a cell you can use the CELL worksheet function, e.g.
=CELL("address",E5) in E5 will give $E$5
--
HTH

Simon


"Liosan" wrote:


Hello people,

If I have a user-defined function that I use to, say, calculate a
cumulative total (I know I don't need VBA for this, it's just an
example). Is there any way I can retrieve the address of the cell where
the UDF was called? or determine whether it was called by the user
inside the worksheet or by a diferent function?

If the answer to the first question is no, I will have to pass the cell
address explicitly as a parameter of the UDF. Whats the best way of
doing this? The obvious (for me) solution - passing the column and row
numbers as integers - seems cumbersome. Is it possible to use the A1
notation here?

Thanks for any help,

Liosan


--
Liosan
------------------------------------------------------------------------
Liosan's Profile: http://www.excelforum.com/member.php...o&userid=26296
View this thread: http://www.excelforum.com/showthread...hreadid=396395


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problem with UDF


Thanks Simon, that's exactly what I needed :

--
Liosa
-----------------------------------------------------------------------
Liosan's Profile: http://www.excelforum.com/member.php...fo&userid=2629
View this thread: http://www.excelforum.com/showthread.php?threadid=39639

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Problem with UDF

How about:

If TypeOf Application.Caller Is Range Then
'called from cell
Else
'not called from cell
End If

Liosan wrote:

Hello people,

If I have a user-defined function that I use to, say, calculate a
cumulative total (I know I don't need VBA for this, it's just an
example). Is there any way I can retrieve the address of the cell where
the UDF was called? or determine whether it was called by the user
inside the worksheet or by a diferent function?

If the answer to the first question is no, I will have to pass the cell
address explicitly as a parameter of the UDF. Whats the best way of
doing this? The obvious (for me) solution - passing the column and row
numbers as integers - seems cumbersome. Is it possible to use the A1
notation here?

Thanks for any help,

Liosan

--
Liosan
------------------------------------------------------------------------
Liosan's Profile: http://www.excelforum.com/member.php...o&userid=26296
View this thread: http://www.excelforum.com/showthread...hreadid=396395


--

Dave Peterson
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM
Problem when multipple users access shared xl-file at the same time, macrocode for solve this problem? OCI Excel Programming 0 May 16th 04 10:40 PM


All times are GMT +1. The time now is 11:53 PM.

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"