Autofilter problem
On Sat, 28 Jul 2012 14:17:07 -0700 (PDT), Ludo wrote:
Hi,
Excel 2007/2010
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.
Any idea what i'm doing wrong?
Sub FilterByToday()
'
Dim w As Worksheet
Dim RngToFilter As Range
Dim strToday As String
'get actual date
strToday = Date
I'm pretty sure that the date needs to be in the format of m/d/yyyy. VBA is US-Centric
So try strToday = format(date, "m/d/yyyy")
|