T
Tara H
I have a workbook with a large amount of data. One of the columns contains
dates. I want to display all of the rows with a date more than a month ago
(to delete in a later step), and have used an advanced filter to do this.
I have the formula '=Today()-30' in cell H2. Cell I1 has the column header
'Date' copied to it, and cell I2 has '="<"&TEXT(H2,"dd/mm/yyyy")'.
This works perfectly when I do it manually, but when I run a macro using:
Range("A9:LastCell").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("I1:I2"), Unique:=False
all of the rows are hidden.
'LastCell' is correctly named, by the following script:
Selection.SpecialCells(xlCellTypeLastCell).Select
ActiveWorkbook.Names.Add Name:="LastCell", RefersTo:=ActiveCell
If I break the code just before the line where the actual filtering happens
and do the filter manually using '$A$9:LastCell' as the source data and
'Criteria' as the criteria, it works as I expect.
My headers are in row 9 (columns A to N) because of the way the report comes
to me, I use some cells in the rows above to keep my criteria in.
I've tried everything I can think of - does anyone know what I'm doing wrong
here?
Many thanks in advance for any help.
Tara H
dates. I want to display all of the rows with a date more than a month ago
(to delete in a later step), and have used an advanced filter to do this.
I have the formula '=Today()-30' in cell H2. Cell I1 has the column header
'Date' copied to it, and cell I2 has '="<"&TEXT(H2,"dd/mm/yyyy")'.
This works perfectly when I do it manually, but when I run a macro using:
Range("A9:LastCell").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("I1:I2"), Unique:=False
all of the rows are hidden.
'LastCell' is correctly named, by the following script:
Selection.SpecialCells(xlCellTypeLastCell).Select
ActiveWorkbook.Names.Add Name:="LastCell", RefersTo:=ActiveCell
If I break the code just before the line where the actual filtering happens
and do the filter manually using '$A$9:LastCell' as the source data and
'Criteria' as the criteria, it works as I expect.
My headers are in row 9 (columns A to N) because of the way the report comes
to me, I use some cells in the rows above to keep my criteria in.
I've tried everything I can think of - does anyone know what I'm doing wrong
here?
Many thanks in advance for any help.
Tara H