Find row number

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
Hello,

I need a row numbers of the last pairs are highlighted in the green in the range C6:E53. Formula or VBA
For examples...
Last pair 25 | 9 find in cells C47:C48 result row number i want in cell C3 = 48
Last pair 25 | H find in cells C32:C33 result row number i want in cell C3 = 33
Last pair 25 | 25 find in cells C25:C26 result row number i want in cell C3 = 26


Book1
ABCDE
125 | 925 | H25 | 25
2
3Row Nun483326
4
5n1n2n3
6HHH
7HHH
8HHH
9252525
10999
11HHH
12HHH
13999
14999
15999
16HHH
17999
18999
19999
20252525
21999
22252525
23999
24252525
25252525
26252525
27999
28252525
29HHH
30252525
31999
32252525
33HHH
34999
35HHH
36999
37999
38252525
39999
40999
41999
42252525
43999
44HHH
45252525
46999
47252525
48999
49999
50999
51HHH
52999
53252525
Sheet1


Thank you all

Excel 2000
Regards,
Moti
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
@ motilulla:

See if the following UDF (User-Defined Function) works for you:
Code:
Function FindPairRow(S1 As String, S2 As String, Rng As Range) As Long
    FindPairRow = Evaluate("LOOKUP(2,1/((" & Rng.Resize(Rng.Rows.Count - 1).Address & "&"" | ""&" & Rng.Offset(1).Resize(Rng.Rows.Count - 1).Address & ")=""" & S1 & " | " & S2 & """),ROW(" & Rng.Offset(1).Resize(Rng.Rows.Count - 1).Address & "))")
End Function

Usage example: =FindPairRow(25,"H",C6:C53)
 
Upvote 0
@ motilulla:

See if the following UDF (User-Defined Function) works for you:
Code:
Function FindPairRow(S1 As String, S2 As String, Rng As Range) As Long
    FindPairRow = Evaluate("LOOKUP(2,1/((" & Rng.Resize(Rng.Rows.Count - 1).Address & "&"" | ""&" & Rng.Offset(1).Resize(Rng.Rows.Count - 1).Address & ")=""" & S1 & " | " & S2 & """),ROW(" & Rng.Offset(1).Resize(Rng.Rows.Count - 1).Address & "))")
End Function

Usage example: =FindPairRow(25,"H",C6:C53)
Tetra201, thank you for giving a 2nd option, your formula works fine also why I want a VBA because once you run you get the results values only, it is preferable if possible </SPAN></SPAN>

I appreciate a lot your kind help
</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Moti
</SPAN></SPAN>:biggrin:
 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,125,000
Members
449,202
Latest member
Pertotal

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top