Whoops, Rick -- my bad. Your code does work.
The problem was that I tested it when I had fewer than 10
dates in the date column. I added an "On Error" statement
and now it works. Still wondering about my other questions,
though. Thanks again!
Sarah
-----------------
First, let me say what a joy it was to read your response... you actually
read and analyze the code posted in response to your questions in an effort
to understand how it works. All too often, the code we volunteers post on
the newsgroups simply gets copied into a poster's code without them giving
it a second thought.
Okay, as to your pending questions (I see from your other response to this
sub-thread that you got the error problem resolved)...
>> And what is CDate? Both you and Chip used it.
>> Well, now I've found what it is via a web search,
>> but I still don't quite see why the value in the date
>> column isn't sufficient on its own so that we need
>> to convert it to CDate. Maybe you can explain
>> that part?)
You are probably right... CDate may not be needed. The thing I was concerned
about (and didn't test any further) was that the underlying value for a date
is an integer value and that Format might not automatically coerce it to a
date before attempting to operate on it. In a quick test, it looks like the
Format function does indeed perform the coercion (probably because d, m and
y is being used in the "format string"), so you can probably safely remove
the CDate function call (although explicitly performing the coercion can
never be wrong).
>> After I digested yours and Chip's I started thinking
>> of a new approach. I don't know if it's better or
[quoted text clipped - 3 lines]
>> technique you both suggested) and then simply deleting
>> cells that are smaller than that value?
That may work for you depending on whether you can have duplicate dates and
what you actually meant by 1. The method I used creates a range of the
**first** 10 largest dates it finds and uses that to parse away the rest of
the dates. Where this matters is with a set of dates like this... 1/1/2008,
1/1/2008, 1/1/2008, 1/1/2008, 1/1/2008, 1/2/2008, 1/3/2008, 1/4/2008,
1/5/2008, 1/6/2008, 1/7/2008, 1/8/2008... note there are 12 dates in the set
with the first 5 of them being the same. My method will take the last 10 of
them and delete the first two dates (even though they match other dates in
the set) along with all earlier dates leaving 10 cells not deleted. Your
method, because if finds the 10th largest date and deletes all previous
dates will leave 12 cells not deleted. If you will not have duplicated
dates, then either method will work the same and your proposed method would
probably be the simpler one.

Signature
Rick (MVP - Excel)
> Whoops, Rick -- my bad. Your code does work.
> The problem was that I tested it when I had fewer than 10
[quoted text clipped - 87 lines]
>>>> of dates except for the most recent 10 entries. Can someone show me
>>>> how?
Sarah H. - 13 Oct 2008 00:37 GMT
Rick,
Thanks a lot -- I appreciate the further explanation. Interesting as to the
handling of multiple dates. Yes, in my case, it's not a problem, but I
will keep the consideration in mind for this situation should it develop
differently and also for further VBA uses.
Sarah
> First, let me say what a joy it was to read your response... you actually
> read and analyze the code posted in response to your questions in an
[quoted text clipped - 42 lines]
> not have duplicated dates, then either method will work the same and your
> proposed method would probably be the simpler one.