Thread: Date Selection
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Date Selection

Nice ambiguous date examples. It is easy to see whether your dates are m/d
or d/m

In the same spirit, turn on the macro recorder and apply an autofilter to
your data. Select the appropriate criteria. Delete the visible rows.

Now turn off the macro recorder and look at the recorded code.

Replace the Criteria with something akin to

= format(DateSerial(year(date),month(date)-18,day(date)),"m/d/yyyy")

From the immediate window for demo:
? format(DateSerial(year(date),month(date)-18,day(date)),"m/d/yyyy")
12/27/2005

--
Regards,
Tom Ogilvy



"bodhisatvaofboogie" wrote:

I have a macro that ends with a resulting list of parts. One column has a
Date Added column and I want to select specific dates within it. I want
parts with a date of the last 18 months selected and deleted. Now I'm not
certain what the code would look like in the macro. Is there a way to select
everything with the date of the last 18 months?

The date is in this format:

1/1/2006 = January 1, 2006
12/12/2006 = December 12, 2006

etc.

Now I could put it in there probably to select the last 18 months from this
date, though that would hardly be automated, because next month I would have
to go into the code and modify it, then the next month, and so on. I wanted
a universal way of doing it so the last 18 months regardless of the month I'm
in will be selected and deleted. make sense?

Thanks for the help!!!!