Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Code to filter a database displays no rows at all

Good afternoon!

I recorded a macro to filter a database to show records where the entry in
column 1 was between two dates thus:

Sub DateFilterOn()
Range("MainDatabaseStart").AutoFilter Field:=1, _
Criteria1:="=23/10/2007", Operator:=xlAnd, _
Criteria2:="<=22/11/2007"
End Sub

When I run the code, it filters the database down and displays no rows at
all (which is incorrect, as there are loads of them that meet the criteria).
If I then go into Data Filter Custom manually on the first DB column, the
criteria from the code appear in the dialog box and when I click "OK", the
database is correctly filtered.

Can anyone tell me where I'm going wrong, please? Why won't my code filter
my data correctly without the manual intervention?

Thanks in advance.

pete
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Code to filter a database displays no rows at all

Hi Pete

Use the US date format mm/dd/yyyy instead of the DMY you use now in the code



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Pete Rooney" wrote in message ...
Good afternoon!

I recorded a macro to filter a database to show records where the entry in
column 1 was between two dates thus:

Sub DateFilterOn()
Range("MainDatabaseStart").AutoFilter Field:=1, _
Criteria1:="=23/10/2007", Operator:=xlAnd, _
Criteria2:="<=22/11/2007"
End Sub

When I run the code, it filters the database down and displays no rows at
all (which is incorrect, as there are loads of them that meet the criteria).
If I then go into Data Filter Custom manually on the first DB column, the
criteria from the code appear in the dialog box and when I click "OK", the
database is correctly filtered.

Can anyone tell me where I'm going wrong, please? Why won't my code filter
my data correctly without the manual intervention?

Thanks in advance.

pete

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Code to filter a database displays no rows at all

Ron,

Nice to hear from you again!

As usual, spot on answer :-)

Thank you!

Pete

"Ron de Bruin" wrote:

Hi Pete

Use the US date format mm/dd/yyyy instead of the DMY you use now in the code



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Pete Rooney" wrote in message ...
Good afternoon!

I recorded a macro to filter a database to show records where the entry in
column 1 was between two dates thus:

Sub DateFilterOn()
Range("MainDatabaseStart").AutoFilter Field:=1, _
Criteria1:="=23/10/2007", Operator:=xlAnd, _
Criteria2:="<=22/11/2007"
End Sub

When I run the code, it filters the database down and displays no rows at
all (which is incorrect, as there are loads of them that meet the criteria).
If I then go into Data Filter Custom manually on the first DB column, the
criteria from the code appear in the dialog box and when I click "OK", the
database is correctly filtered.

Can anyone tell me where I'm going wrong, please? Why won't my code filter
my data correctly without the manual intervention?

Thanks in advance.

pete


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP: VBA Code to extract data from an SQL Server database and put it into Access Database Clinton M James[_2_] Excel Programming 1 October 8th 07 12:44 AM
Worksheet change code to colour in rows in a database Peter Rooney Excel Programming 7 May 19th 06 11:36 AM
Custom Filter that Displays All But in Ascending or Decending Orde Kim Excel Discussion (Misc queries) 3 September 14th 05 07:46 PM
Clicking on listbox control displays code - why? Mark[_51_] Excel Programming 1 September 14th 04 04:41 AM
Hidden rows Database Filter Charley Kyd[_2_] Excel Programming 3 March 3rd 04 12:19 AM


All times are GMT +1. The time now is 09:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"