Autofilter problem
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
|