Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Windows XP - Excel 2000
Hello, I'm trying to make a function that returns the row number of the cell in range SAR where string CRIT appears for the first time. The purpose is to use the result as an argument in an INDEX function to retrieve the value of the intersection of a certain row and column. The INDEX(MATCH,MATCH) formula is useless in this case since the horizontal criteria are not on the same row. What is wrong with the following code ? I always get the #VALUE! result. (I know about line breaking underscores missing in this message. They are OK in the module.) Function GetRowNumber(SAR As Range, CRIT As String) As Long GetRowNumber = SAR.Find(What:=CRIT, After:=SAR.Range("A1"), LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Row End Function THE FOLLOWING SUB-VERSION WORKS FINE THOUGH. Sub RowNum() Dim SAR As Range, CRIT As String Set SAR = Application.InputBox("Select Search Area", Type:=8) CRIT = Application.InputBox("Enter Search Value", Type:=2) MsgBox SAR.Find(What:=CRIT, After:=SAR.Range("A1"), LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Row End Sub Can anyone help me out here? Thank you very much Herman |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
BreakLinks method doesn't work. | Excel Discussion (Misc queries) | |||
How Come Calcs are wrong when verifing totals to items method | Excel Worksheet Functions | |||
Using variables to make a date and using find method to find that. | Excel Programming | |||
Find Method doesn't work | Excel Programming | |||
Cant get my code work. Find file or create it | Excel Programming |