ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find last value in range (https://www.excelbanter.com/excel-programming/353310-find-last-value-range.html)

Todd Huttenstine

Find last value in range
 
I have in Column A 10 values. Cells A1:A5 have the value "test".
Cells A6:A10 have other values. I would like to return the value "A5"
as this is the last cell in this range to contain the value "test"

I am interested in only returning the last cell that contains my
specified lookup value. Starting from the bottom of the range and
going to the top. I guess this would also be going at it by starting
from the bottom of the sheet looking up. Anyway, any help is
appreciated.


Thanks
Todd


Ron de Bruin

Find last value in range
 
Try this Todd

Sub Find_Last()
Dim FindString As String
Dim rng As Range
FindString = InputBox("Enter a Search value")
If Trim(FindString) < "" Then
With Sheets("Sheet1").Range("A:A")
Set rng = .Find(What:=FindString, _
After:=.Cells(1), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False)
If Not rng Is Nothing Then
Application.Goto rng, True
Else
MsgBox "Nothing found"
End If
End With
End If
End Sub


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


"Todd Huttenstine" wrote in message
oups.com...
I have in Column A 10 values. Cells A1:A5 have the value "test".
Cells A6:A10 have other values. I would like to return the value "A5"
as this is the last cell in this range to contain the value "test"

I am interested in only returning the last cell that contains my
specified lookup value. Starting from the bottom of the range and
going to the top. I guess this would also be going at it by starting
from the bottom of the sheet looking up. Anyway, any help is
appreciated.


Thanks
Todd





All times are GMT +1. The time now is 01:13 AM.

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