ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Help with using filter criteria with date (https://www.excelbanter.com/excel-worksheet-functions/60468-help-using-filter-criteria-date.html)

[email protected]

Help with using filter criteria with date
 

This one has me puzzled...

In previous macros I've used this code if I wanted the criteria value
to = a value in a cell somewhere else.

Sheets("Data 1").Select
Selection.AutoFilter Field:=7, Criteria1:=Sheets("Report").Range("A1"),
Operator:=xlAnd

In this case for example, cell A1 in Report worksheet has a value of
"test". So in the Data 1 worksheet, it would find all rows with "test"
in Column G (pretty simple).

I seem to be having difficulty using the same method above when
instead of using a word like "test", I'm using a date, like 12/11/05 in
my Report worksheet, cell A1. There are plenty of dates with 12/11/05
in the Data 1 sheet so I'm puzzled.

I've double checked the format of the cell in A1 to make sure it's the
same format as the dates in Column G in Data 1 and everthing is in
synch.

Any ideas?


Bob Phillips

Help with using filter criteria with date
 
Try

Sheets("Data 1").AutoFilter Field:=7,
Criteria1:=Sheets("Report").Range("A1").Text, Operator:=xlAnd


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

wrote in message
ps.com...

This one has me puzzled...

In previous macros I've used this code if I wanted the criteria value
to = a value in a cell somewhere else.

Sheets("Data 1").Select
Selection.AutoFilter Field:=7, Criteria1:=Sheets("Report").Range("A1"),
Operator:=xlAnd

In this case for example, cell A1 in Report worksheet has a value of
"test". So in the Data 1 worksheet, it would find all rows with "test"
in Column G (pretty simple).

I seem to be having difficulty using the same method above when
instead of using a word like "test", I'm using a date, like 12/11/05 in
my Report worksheet, cell A1. There are plenty of dates with 12/11/05
in the Data 1 sheet so I'm puzzled.

I've double checked the format of the cell in A1 to make sure it's the
same format as the dates in Column G in Data 1 and everthing is in
synch.

Any ideas?





All times are GMT +1. The time now is 04:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com