VBA Excel: Filter by Year Only
Solved
nenuf
-
Morgothal Posted messages 1350 Status Member -
Morgothal Posted messages 1350 Status Member -
Hello everyone,
A quick question about VBA, filters, and dates.
I have data in a column in the format "dd/mm/yyyy", and I want to filter in VBA by selecting only the year...
I managed to retrieve the list of possible years in a cell named "Year", I just want to modify the following line:
ActiveSheet.Range("$B$12:$AE$2500").AutoFilter Field:=4, Criteria1:=Year
Because here, of course, it finds nothing since my column doesn't only contain the year... One clarification: I can't modify my table to insert a column or anything else.
Thanks in advance!
A quick question about VBA, filters, and dates.
I have data in a column in the format "dd/mm/yyyy", and I want to filter in VBA by selecting only the year...
I managed to retrieve the list of possible years in a cell named "Year", I just want to modify the following line:
ActiveSheet.Range("$B$12:$AE$2500").AutoFilter Field:=4, Criteria1:=Year
Because here, of course, it finds nothing since my column doesn't only contain the year... One clarification: I can't modify my table to insert a column or anything else.
Thanks in advance!
Unless I set a criterion like >= 00/00/Year and <00/00/Year+1! I will explore this avenue.
ActiveSheet.Range("$B$12:$AE$2503").AutoFilter Field:=1, Criteria1:=">=1/1/" & Year, Operator:=xlAnd, Criteria2:="<=12/31/" & Year