Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default How do I determine a Function's callling Row Number.

I need to know what ROW a Function is called from.

I am copying a Row with this function call in it to many Rows. The function
has to act on the data in the called row.

The ACTIVECELL pointer stays constant over all the calls, so that isn't
useful. I suppose I could generate a Column of Row Numbers and pass that in
the actual function call, ...

But isn't there a more elegant solution?

Thanks,
Mac Lingo


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default How do I determine a Function's callling Row Number. Here is "A" Solution.

There is probably a more elegant way to do this, but the following
Subroutine & Function does return it.
Mac

Sub Calling_Address(RowNr, ColNr)
' Return Calling RowNr and ColNr.
Dim TS As String
Const xCharacters = "ABCDEFGHIJKLMNOPQRSTWXYZ"
Const xNumbers = "0123456789"

Select Case TypeName(Application.Caller)
Case "Range"
TS = Mid(Application.Caller.Address, 2, 99)
ColNr = GetRowColNr(TS, xCharacters, 26, 0)
TS = Mid(TS, 2, 999)
RowNr = GetRowColNr(TS, xNumbers, 10, 1)
Case Else
RowNr = -1
ColNr = -1

End Select

End Sub ' Calling_Address

Function GetRowColNr(ARG_STRING, TEST_CHARS, POWER, OFFSET) As Integer
' Take character of ARG_TYPE off ARG_STRING and return its
' numeric equalivent.
' This is to decode R1C1 type addresses.

Dim TS As String
Dim PTR As Integer

Pull_Number = 0

Do While Len(ARG_STRING)
TS = UCase(Left(ARG_STRING, 1))

PTR = InStr(TEST_CHARS, TS)
If (PTR) Then
Pull_Number = Pull_Number * POWER + (PTR - OFFSET)
Else
Exit Function
End If

ARG_STRING = Mid(ARG_STRING, 2, 99)
Loop



End Function ' GetRowColNr


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do I determine a Function's callling Row Number.

Same as the last time you asked.

dim rng as Range
set rng = application.Caller
myrow = rng.row

--
Regards,
Tom Ogilvy

"Mac Lingo" wrote in message
link.net...
I need to know what ROW a Function is called from.

I am copying a Row with this function call in it to many Rows. The

function
has to act on the data in the called row.

The ACTIVECELL pointer stays constant over all the calls, so that isn't
useful. I suppose I could generate a Column of Row Numbers and pass that

in
the actual function call, ...

But isn't there a more elegant solution?

Thanks,
Mac Lingo




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
use function to change a string to function's parameter ViestaWu Excel Worksheet Functions 3 November 21st 07 12:42 PM
Cells display function's text rather than its results tonerowlabs Excel Discussion (Misc queries) 4 July 8th 06 12:47 PM
A correct IF function doesn't show the function's result in cell Michael Excel Discussion (Misc queries) 1 April 10th 06 09:10 AM
want sumif function's range to evaluate 2 columns Debgala Excel Worksheet Functions 7 November 6th 05 03:46 AM
Updating a Function's Result Syed Zeeshan Haider[_5_] Excel Programming 8 December 6th 03 09:32 PM


All times are GMT +1. The time now is 07:21 AM.

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"