Hello,
I wish to use VBS to autofilter a certain column, but it's a little bit confusing.
I have a date format column where I wish to filter, first by year.
I have developed this code:
Dim arrayCloseYears() As Variant
arrayCloseYears = Array("< 1/1/2011", "> 12/31/2011")
ActiveSheet.UsedRange.AutoFilter Field:=13, Criteria1:=arrayCloseYears, Operator:=xlFilterValues
Unfortunately, it doesn't work.
After filtering by year I need delete the resulting records and then perform a second filtering by day of 2012 (let's say, everythinf before the 25th of May for example).
I used tha macro recordar, but it displays teh following code:
ActiveSheet.Range("$A$1:$O$45878").AutoFilter Field:=13, Operator:= _
xlFilterValues, Criteria2:=Array(0, "12/31/2011")
but I don't understand how the array is used.
When filtering by day I obtain:
ActiveSheet.Range("$A$1:$O$11959").AutoFilter Field:=13, Operator:= _
xlFilterValues, Criteria2:=Array(1, "1/31/2012", 1, "2/29/2012", 1, "3/31/2012", 1, _
"4/30/2012", 2, "5/1/2012", 2, "5/2/2012", 2, "5/3/2012", 2, "5/4/2012", 2, "5/5/2012", 2, _
"5/6/2012", 2, "5/7/2012", 2, "5/8/2012", 2, "5/9/2012", 2, "5/10/2012", 2, "5/11/2012", 2 _
, "5/12/2012", 2, "5/13/2012", 2, "5/14/2012", 2, "5/15/2012", 2, "5/16/2012", 2, _
"5/17/2012", 2, "5/18/2012", 2, "5/19/2012", 2, "5/20/2012")
But I need this to be something dynamic. I can't write all the dates because the code is going to be used in different dates And I want to filter accordin to a date a user will give me through a date variable.
I would much appreciate your assistance.
Bookmarks