Find Value searching UP

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
T

Todd Huttenstine

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top