Sarah,
Try code like the following. Change the reference to A1:A100 to the
appropriate range.
Sub AAA()
Dim Keep1 As Date
Dim Keep2 As Date
Dim R As Range
Dim RR As Range
Keep1 =
CDate(Application.WorksheetFunction.Large(Range("A 1:A100"), 10))
Keep2 = Application.WorksheetFunction.Max(Range("A1:A100") )
Set R = Cells(Rows.Count, "A").End(xlUp)
Do Until R.Row = 1
If Keep1 <= R.Value And R.Value <= Keep2 Then
' R is within 10 entries. do nothing.
Else
If RR Is Nothing Then
Set RR = R
Else
Set RR = Application.Union(RR, R)
End If
End If
Set R = R(0, 1)
Loop
If Not RR Is Nothing Then
RR.EntireRow.Delete
End If
End Sub
Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
The San Diego Project Group, LLC
(email is on the web site)
USA Central Daylight Time (-5:00 GMT)
On Sat, 11 Oct 2008 18:28:49 +0200, "Sarah H."
wrote:
Hi, all,
I'm stuck and hope you can offer some help.
I know a bit about VBA programming but am having trouble writing
code to do the following: I wish to delete all date values in a column
of dates except for the most recent 10 entries. Can someone show me how?