I am writing the code to delete the records with the oldest date in the table, using the function to find the end of the range. I never get the "endrow" value back to the sub. Appreciate any suggestion.
StartDate = ActiveSheet.Cells(2, 1).Value
EndDate = StartDate
startrow = 2
endrow = FindEndDate(EndDate)
Rows(startrow & ":" & endrow).EntireRow.Delete
Function FindEndDate(ByVal EndDate As Date) As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = lastrow To 2 Step -1
If Cells(i, 1).Value = EndDate Then
endrow = i
Exit For
End If
Next i
End Function