Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Identifying cell from which a call is made

Is there a way for a VBA/Excel function to identify the
cell (row and column) from which a call is made to it.

For example

A1: MyFunc( $B1)
A2: MyFunc( $B2)
A3: MyFunc( $B3)
etc.

Function MyFunc( X as Integer) as Integer
MyFunc = RowCalledFrom() + ColumnCalledFrom + X
End Function

So, is there something to perform the role of the mythical
functions RowCalledFrom() and ColumnCalledFrom()?

One alternative would be to change MyFunc a bit to pass the
row and column explicitly:

A1: MyFunc2( Row(), Column(), $B1)
A2: MyFunc2( Row(), Column(), $B2)
etc.

Function MyFunc2(
R as Intgeger, C as Integer, X as Integer) as Integer
MyFunc = R + C + X
End Function

But it would be nice if there a way for MyFunc to know the
row and column without explicitly being passed them. Is there?

Note that this has nothing to do with the Active cell or
the Selection.

Thanks. --David.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Identifying cell from which a call is made

David,

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


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


"David Lewis" wrote in
message ...
Is there a way for a VBA/Excel function to identify the
cell (row and column) from which a call is made to it.

For example

A1: MyFunc( $B1)
A2: MyFunc( $B2)
A3: MyFunc( $B3)
etc.

Function MyFunc( X as Integer) as Integer
MyFunc = RowCalledFrom() + ColumnCalledFrom + X
End Function

So, is there something to perform the role of the mythical
functions RowCalledFrom() and ColumnCalledFrom()?

One alternative would be to change MyFunc a bit to pass the
row and column explicitly:

A1: MyFunc2( Row(), Column(), $B1)
A2: MyFunc2( Row(), Column(), $B2)
etc.

Function MyFunc2(
R as Intgeger, C as Integer, X as Integer) as Integer
MyFunc = R + C + X
End Function

But it would be nice if there a way for MyFunc to know the
row and column without explicitly being passed them. Is there?

Note that this has nothing to do with the Active cell or
the Selection.

Thanks. --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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Identifying who made a comment in 2007 LAClarkbar Excel Discussion (Misc queries) 1 December 4th 09 04:21 PM
Identifying text within a cell Bob Freeman Excel Discussion (Misc queries) 9 August 28th 08 08:17 PM
Identifying Current Cell kaayyes Excel Worksheet Functions 8 June 8th 07 03:30 PM
Identifying a cell/value in a table Ian Murdoch Excel Discussion (Misc queries) 5 August 1st 06 05:26 AM
Call Center Management: How to calculate 'cost per call' Denniso6 Excel Discussion (Misc queries) 2 June 25th 06 05:01 PM


All times are GMT +1. The time now is 01:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"