NewOrderFac33
Well-known Member
- Joined
- Sep 26, 2011
- Messages
- 1,283
- Office Version
- 2016
- 2010
- Platform
- Windows
Good afternoon,
When I use the following code to filter an Excel database to all rows where the date in the first field is less than or equal to the value in the named range "DeleteOldest"
my procedure filters my database and returns data rows correctly
However, when I use a variation on the above to return rows where the date in the first field is equal to the value in the named range "DeleteNewest"
no rows are returned (although there are several)
If I change my criteria string to
it works fine, and, for the purposes of my dataset, this is also fine, as there are no rows with a date value value greater than "DeleteNewest"
So, it works with >= and <= but not = alone.
Can anyone suggest why this might be?
Thanks in advance
Pete
When I use the following code to filter an Excel database to all rows where the date in the first field is less than or equal to the value in the named range "DeleteOldest"
Code:
DODCriteriaString = "<=" & Format(Sheets("Database").Range("DeleteOldest").value, "yyyy/mm/dd")
ActiveSheet.Range("Database").AutoFilter Field:=1, Criteria1:=DODCriteriaString, Operator:=xlAnd
However, when I use a variation on the above to return rows where the date in the first field is equal to the value in the named range "DeleteNewest"
Code:
DNDCriteriaString = "=" & Format(Sheets("Database").Range("DeleteNewest").value, "yyyy/mm/dd")
ActiveSheet.Range("Database").AutoFilter Field:=1, Criteria1:=DNDCriteriaString, Operator:=xlAnd
If I change my criteria string to
Code:
DNDCriteriaString = ">=" & Format(Sheets("Database").Range("DeleteNewest").value, "yyyy/mm/dd")
So, it works with >= and <= but not = alone.
Can anyone suggest why this might be?
Thanks in advance
Pete
Last edited: