r1998
Board Regular
- Joined
- Sep 9, 2018
- Messages
- 106
Dear Friends and Respected Seniors,
i have this data in sheet2 starting from cells a1:b9
[TABLE="width: 128"]
<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]a[/TD]
[TD="width: 64, align: right"]8[/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]h[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]j[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]k[/TD]
[TD="align: right"]85[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD="align: right"]65[/TD]
[/TR]
[TR]
[TD]u[/TD]
[TD="align: right"]47[/TD]
[/TR]
[TR]
[TD]i[/TD]
[TD="align: right"]11[/TD]
[/TR]
</tbody>[/TABLE]
I want to get the value from column B when value in column A is character b...... so the value will be 5
then I want to get the value from column B when value in column A is character j...... so the value will be 3
then i want to get the maximum value of this range starting from 5 and ending at 3....
the range will be
5
2
4
3
and its Maximum value will be 5
I am able to do this with VBA code,
but I want to do this with a formula n i am not able to figure out how to do it :|
Please can anyone kindly help and guide me
Awaiting your replies.
Thank you.
i have this data in sheet2 starting from cells a1:b9
[TABLE="width: 128"]
<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>[TR]
[TD="width: 64"]a[/TD]
[TD="width: 64, align: right"]8[/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]h[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]j[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]k[/TD]
[TD="align: right"]85[/TD]
[/TR]
[TR]
[TD]y[/TD]
[TD="align: right"]65[/TD]
[/TR]
[TR]
[TD]u[/TD]
[TD="align: right"]47[/TD]
[/TR]
[TR]
[TD]i[/TD]
[TD="align: right"]11[/TD]
[/TR]
</tbody>[/TABLE]
I want to get the value from column B when value in column A is character b...... so the value will be 5
then I want to get the value from column B when value in column A is character j...... so the value will be 3
then i want to get the maximum value of this range starting from 5 and ending at 3....
the range will be
5
2
4
3
and its Maximum value will be 5
I am able to do this with VBA code,
but I want to do this with a formula n i am not able to figure out how to do it :|
Code:
Sub e()
Dim i As Integer, a As Integer, b As Integer
For i = 1 To Sheet2.Range("b1").End(xlDown).Row
If (Cells(i, 1) = "b") Then
a = i
End If
If (Cells(i, 1) = "j") Then
b = i
End If
Next
Sheet2.Range(Cells(a, 2), Cells(b, 2)).Select
Sheet2.Range("c1") = Application.Max(Sheet2.Range(Cells(a, 2), Cells(b, 2)))
End Sub
Awaiting your replies.
Thank you.