View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Ludo Ludo is offline
external usenet poster
 
Posts: 74
Default Autofilter problem

Op zaterdag 28 juli 2012 23:37:25 UTC+2 schreef Claus Busch het volgende:
Hi Ludo,



Am Sat, 28 Jul 2012 14:17:07 -0700 (PDT) schrieb Ludo:



I'm trying to use the autofilter on a range using the actual date as a criteria.


I have following code but it fails on the indicated code line.




once i can autofilter for the actual date, then i need to select the apropriate data from columns B:D (visible rows) to send them to a recipient with mail.


For sending mail, i'll visit the site of Ron De Bruin.




I expect that RngToFilter is a valid range, so hoping i can address this imediately in the code as follow:


RngToFilter.AutoFilter Field:=1, Operator:=xlFilterValues, Criteria2:=Array(2, strToday)'<<<<<< error 1004 Method Autofilter from Class Range fails


but it fails.




Try:



Sub FilterByToday()



Dim wsh As Worksheet

Dim RngToFilter As Range



Set wsh = Worksheets("Sheet1")

With wsh

.AutoFilterMode = False

Set RngToFilter = .Cells.CurrentRegion

RngToFilter.AutoFilter Field:=1, Criteria1:=xlFilterToday, _

Operator:=xlFilterDynamic

End With



Set RngToFilter = Nothing

Set wsh = Nothing

End Sub



Regards

Claus Busch

--

Win XP PRof SP2 / Vista Ultimate SP2

Office 2003 SP2 /2007 Ultimate SP2


Hi Claus,

Thanks for the info.
It works fine.

Additional question:
How did you know that you can use Criteria1:=xlFilterToday?
I can't find this back in the Help for Excel.
I guess that this knowledge belongs to the real experts :).

Where can i find more 'expert' info abouth this topic (Autofilter)?

Regards,
Ludo