PDA

View Full Version : [SOLVED:] Extracting Row Number using VBA Function..



surya prakash
04-23-2008, 09:41 PM
Hi,
I am wondering if it is possible to return the row number using VBA user defined function.

Will appreciate any feedback...

thanks


Private Function Extract_Rowno(ByVal text1 As String)
Extract_Rowno = Row()
End Function

JimmyTheHand
04-23-2008, 10:53 PM
Hi
What is it you are trying to extract rownumber from? What is text1?
Is it an address format, like "$A$3"? Or?

If it is, then

Extract_Rowno = Val(Mid(text1, InStrRev(text1, "$") + 1))

If the function aims to return the rownumber of a cell (as argument of the function) then


Function Extract_Rowno(Cell As Range) As Long
Extract_Rowno = Cell.Row
End Function


Jimmy

mdmackillop
04-24-2008, 12:47 AM
If you need to find the text then something like


Sub test()
MsgBox Extract_Rowno("test")
End Sub

Private Function Extract_Rowno(ByVal text1 As String)
Extract_Rowno = Columns(1).Find(text1).Row
End Function

rory
04-24-2008, 05:00 AM
Why use a UDF when the ROW() function already exists, as a matter of interest?