When setting up the data, you can use the MATCH function to get the line number:
=MATCH(1,INDEX(($A$1:$A$6="id2")*($B$1:$B$6="day1"),),0)
If there are no matches for these criteria, the formula will return # N / A error. You can also change the criteria as cell references, for example:
=MATCH(1,INDEX(($A$1:$A$6=F1)*($B$1:$B$6=G1),),0)
In the second part of your question, returning the values ββwith the found row number, you can use the INDEX function to return the value from the column. Therefore, pretending that the Match formula is in cell H1, these two formulas return the value from columns C and D, respectively:
=INDEX($C$1:$C$6,H1) =INDEX($D$1:$D$6,H1)
Alternatively, you can put all this into one formula:
=INDEX($C$1:$C$6,MATCH(1,INDEX(($A$1:$A$6=F1)*($B$1:$B$6=G1),),0))
And if you do not want to look at errors, you can use IFERROR on excel 2007 +
=IFERROR(INDEX($C$1:$C$6,MATCH(1,INDEX(($A$1:$A$6=F1)*($B$1:$B$6=G1),),0)),"No Matches")
Error checking for Excel 2003 and below:
=IF(ISNA(MATCH(1,INDEX(($A$1:$A$6=F1)*($B$1:$B$6=G1),),0)),"No Matches",INDEX($C$1:$C$6,MATCH(1,INDEX(($A$1:$A$6=F1)*($B$1:$B$6=G1),),0)))
[EDIT]: I include a VBA solution for every user request. This uses a search loop that is very efficient and flexible, and shows how to retrieve values ββfrom other columns after a match is found:
Sub tgr() Dim rngFound As Range Dim strFirst As String Dim strID As String Dim strDay As String strID = "id2" strDay = "day1" Set rngFound = Columns("A").Find(strID, Cells(Rows.Count, "A"), xlValues, xlWhole) If Not rngFound Is Nothing Then strFirst = rngFound.Address Do If LCase(Cells(rngFound.Row, "B").Text) = LCase(strDay) Then 'Found a match MsgBox "Found a match at: " & rngFound.Row & Chr(10) & _ "Value in column C: " & Cells(rngFound.Row, "C").Text & Chr(10) & _ "Value in column D: " & Cells(rngFound.Row, "D").Text End If Set rngFound = Columns("A").Find(strID, rngFound, xlValues, xlWhole) Loop While rngFound.Address <> strFirst End If Set rngFound = Nothing End Sub