Excel Recorded Macro Advanced Filter Error

Viewed 34

I work on a team that deals with a lot of data on a daily basis. I have a 60k+ entry sheet that I need to provide a simple filtering solution to, for a client.

I decided to go with an advanced filter macro, which takes the criteria from a sheet, filters the database and outputs it to a third sheet.

It worked wonderfully when operated manually. Problem is, when I record the Macro and try to use it, the output is blank, only the headers are copied to the output. The problem occurs specifically when using the date interval criteria (I copied the date header twice and I'm using intervals to filter through, e.g.: first date criteria: >/01/01/2022, second date criteria: <01/02/2022.

I don't think it's a problem with the database because, as I said, the filter works when applied manually.

I tried cleaning up the recorded macro code but it didn't solve anything. Here are both versions:

-Base Macro:

Sub filtrar2()
'
' filtrar2 Macro
'

'
    Sheets("resultados").Select
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    Sheets("base").Range("A1:X60885").AdvancedFilter Action:=xlFilterCopy, _
        CriteriaRange:=Sheets("filtro").Range("A2:K3"), CopyToRange:=Range("A1"), _
        Unique:=False
End Sub

-Clean Macro:

Sub FILTRAR()
'
' FILTRAR Macro
'

'
    Sheets("base").Range("A1:X60885").AdvancedFilter Action:=xlFilterCopy, _
        CriteriaRange:=Sheets("filtro").Range("A2:K3"), CopyToRange:=Sheets("resultados").Range("A1"), _
        Unique:=False
End Sub
0 Answers
Related