Find last date

mmetzinger

Board Regular
Joined
Dec 30, 2010
Messages
61
Ok, this should be an easy one. I need to figure out how to get the find function to activate the last cell with the found data. The task is to find the last date in a column of dates that may have duplicates. So if you just use the find method it stops at the first cell it finds with the date.

Columns("U").Find(What:=EndDate, After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:=False, SearchFormat:=False).Activate

I need to find the last cell in the column with that date. I cannot resort the data to make it show up first because I am establishing a row range to copy to a new sheet.

Any help?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Code:
Sub test()
Dim Last_Row As Long, n As Long

Last_Row = Range("U" & Rows.Count).End(xlUp).Row

For n = Last_Row To 2 Step -1
    If Cells(n, 21) = WorksheetFunction.Max(Range("U:U")) Then
        Cells(n, 21).Select
        Exit Sub
    End If
Next n
End Sub
 
Upvote 0
Code:
Columns("U").Find(What:=EndDate,[COLOR="Red"] After:=Range("U1")[/COLOR], _
LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
[COLOR="Red"]SearchDirection:=xlPrevious[/COLOR], MatchCase:=False, SearchFormat:=False).Activate
 
Upvote 0

Forum statistics

Threads
1,215,746
Messages
6,126,639
Members
449,325
Latest member
Hardey6ix

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