View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bradly Bradly is offline
external usenet poster
 
Posts: 39
Default help with dates in the past

Hi. I tried the two FilterRange options you gave--the first one didn't do
anything and the second one listed the majority of the original list, which I
know is not correct. I tried changing the date format of the column, and it
showed it originally listed as "general"--I am thinking the dates that I
import (mm yy) are probably text. The dates didn't change when I changed the
column date format.

I am using Excel 2003 and the regional date settings are m/d/y. Let me know
if there is anything else you need to help. Thanks.


"OssieMac" wrote:

Hi Bradley,

Am I correct in assuming that you want to include all data prior to and
including a specific month?

If the dates in the filtered column are actual dates and formatted to mm yy
then you may only have to change the filter criteria to the following.

FilterRange.AutoFilter Field:=1, Criteria1:="<=Mar-2010"

Excel VBA has problems with numerics in dates when the date to be entered is
a string like used with AutoFilter code. However, I have always been
successful by using the alpha literal month. (For interest in the above,
Excel actually evaluates Mar-2010 as 1- Mar-2010.)

If the above does not work and your regional date format is m/d/y and the
filtered column contains actual dates and formatted to mm yy then try the
following.

FilterRange.AutoFilter Field:=1, Criteria1:="<=Mar-31-2010"

If the above does not work then get back to me with some answers to the
following questions.

What version of xl are you using?

Are the values in the filtered column actual dates and formatted as mm yy or
are they simply text? (I can tell you how to change from text to date format
and display as mm yy but I need an answer to the following question first.)

What is your regional date format (d/m/y or m/d/y)?

--
Regards,

OssieMac


"Bradly" wrote:

Hi.

I currently have a code that correctly filters the case reviews due for a
given month (for my example, it is for March). I want, however, to make a
file that filters all of the past due case reviews. Here is my current code:

Sub GetOverdueReviews()
'
' GetOverdueReviews Macro
'
'

'
Sheets("F Cases").Activate
Application.Goto Reference:="R1C1"


Dim FilterRange As Range
Dim CopyRange As Range
Set FilterRange = Range("L1:L5000") 'Header in row
Set CopyRange = Range("A1:M5000")
FilterRange.AutoFilter Field:=1, Criteria1:="03 10"
CopyRange.SpecialCells(xlCellTypeVisible).Copy _
Destination:=Worksheets("Overdue Reviews").Range("A3")
Application.CutCopyMode = False
Sheets("F Cases").Activate
Selection.AutoFilter
Application.Goto Reference:="R1C1"
Sheets("Overdue Reviews").Activate
Application.Goto Reference:="R1C1"
End Sub

How can this be modified to get all of the past due case reviews (they could
go back as far as 10/2008)? The date format used in my code is "03 10".
Thanks.