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)...
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).
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.