Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Advanced Filtering

Has anyone encountered any issues with range.advanced filtering? I filter on
dates but the function doesnt filter correctly, it returns to many dates.
Works perfectly when done manually via the Advanced option in the ribbon.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Advanced Filtering

Give us some examples
--
Gary''s Student - gsnu201001


"Opa Horst" wrote:

Has anyone encountered any issues with range.advanced filtering? I filter on
dates but the function doesnt filter correctly, it returns to many dates.
Works perfectly when done manually via the Advanced option in the ribbon.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Advanced Filtering

In addition to Gary''s Student's request, you say "Works perfectly when done
manually via the Advanced option in the ribbon". Can you post recorded code
of doing this manually.

--
Regards,

OssieMac


"Opa Horst" wrote:

Has anyone encountered any issues with range.advanced filtering? I filter on
dates but the function doesnt filter correctly, it returns to many dates.
Works perfectly when done manually via the Advanced option in the ribbon.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Advanced Filtering

Thanks for your reply; some details:
Data: Criteria: Result manual: Result with vba:
UsageDate UsageDate UsageDate UsageDate
1/01/2009 =5/01/2009 5/01/2009 2/01/2009
1/01/2009 =6/01/2009 6/01/2009 3/01/2009
2/01/2009 4/01/2009
3/01/2009 5/01/2009
4/01/2009 6/01/2009
5/01/2009 6/01/2009
6/01/2009
6/01/2009

Manual process:
Click Advanced on Data ribbon, specify data and criteria range

VBA:
Range(€śData€ť).AdvancedFilter _
Action:=xlFilterCopy _
, CriteriaRange:=CriteriaRange _
, CopyToRange:=Range(€śResults€ť) _
, Unique:=False

The data and criteria ranges are large; about 500,000 data rows and 260
Criteria rows.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Advanced Filtering

Correction: There are two dates 6/01/2009 in the Manual result.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Advanced Filtering

Hi Opa Horst,

This is an idiosyncrasy of Excel VBA. It does not recognise d/m/y dates as
Filter Criteria with AutoFilter or Advanced Filter. VBA sees the dates as
m/d/y format.

The options below are as you enter them in the formula bar; not necessarily
as they appear in the cell. Only applies to the Filter Criteria; not the main
data.

You can enter them as one of the following
="=1/5/2009"
(m/d/y format) However, then they will not work in the interactive mode.

="=" & DATEVALUE("5/01/2009")
(d/m/y format) However appears as numeric in cell; not as date format.

="=5 Jan 2009"
This is my preference so that everyone knows what it means and it displays
the correct date (in a format that we understand) in the criteria cell. VBA
has no problems when the literal is used for the month.

Just as a little extra. If you were to record code for AutoFiltering dates,
the recorded code shows the dates in d/m/y format but the code will not run
and repeat the filtering. Editing the code and changing to dd mmm yyyy format
fixes the problem.

--
Regards,

OssieMac


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Advanced Filtering

Thanks OssieMac,

This works great, you made my day! :)
The range and criteria are on a temporarily sheet which is deleted after the
filtering, only the result is copied to an other sheet, so I opted for
="m/d/yyyy"
For your information: The dates for the criteria are generated from
information the user enters. They specify a year, months and week days, so
its easy to create the dates in the correct format.
Thanks again,
Opa
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
Advanced Filtering Browny Excel Discussion (Misc queries) 4 September 5th 08 02:30 PM
Advanced 'filtering' raphiel2063 Excel Programming 2 September 3rd 07 05:48 PM
Advanced Filtering [email protected] Excel Discussion (Misc queries) 2 August 20th 07 12:20 AM
Advanced Filtering ksp Excel Programming 6 November 25th 05 07:15 AM
Advanced Filtering in VBA John Pierce Excel Programming 1 October 8th 03 09:51 AM


All times are GMT +1. The time now is 03:02 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"