ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find Value searching UP (https://www.excelbanter.com/excel-programming/353309-find-value-searching-up.html)

Todd Huttenstine

Find Value searching UP
 
Hey

I need to find the last value in a range. Lets say I have values in
A1:A10. In A2:A5 the value is "test". In all other cells in this
range the values are different. My lookup value is "test" I would
like for a vba code to return A5 as A5 is the last cell in the range to
contain my lookup value.


Thanks
todd


Jim May

Find Value searching UP
 
Sub Foo()
Set Rng = Range("A1:A10")
rcount = Rng.Rows.Count
For i = rcount To 1 Step -1
If Cells(i, 1) = "test" Then
MsgBox "Found test at " & Cells(i, 1).Address
Exit Sub
End If
Next i
End Sub

"Todd Huttenstine" wrote:

Hey

I need to find the last value in a range. Lets say I have values in
A1:A10. In A2:A5 the value is "test". In all other cells in this
range the values are different. My lookup value is "test" I would
like for a vba code to return A5 as A5 is the last cell in the range to
contain my lookup value.


Thanks
todd



Ron de Bruin

Find Value searching UP
 
See your other thread

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Todd Huttenstine" wrote in message
oups.com...
Hey

I need to find the last value in a range. Lets say I have values in
A1:A10. In A2:A5 the value is "test". In all other cells in this
range the values are different. My lookup value is "test" I would
like for a vba code to return A5 as A5 is the last cell in the range to
contain my lookup value.


Thanks
todd





All times are GMT +1. The time now is 11:12 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com