Dec 20 2022 03:35 AM - edited Dec 20 2022 04:54 AM
Hi,
I am facing issues when filtering for multiple things in my Macro.
I am filtering on three different criteria's but when clicking the button I have created, instead of filtering all lines go away. I have to manually go into every "custom filter" and press ok. After pressing the last of the three, it does the actual filtering.
The code I have used is as follows :
Sub Sorter_Dato()
'
' Sorter_Dato Macro
'
'
ActiveSheet.Range("$A$13:$AA$2758").AutoFilter Field:=26, Criteria1:="<=" & Date + 7, Operator:=xlOr, Criteria2:="unconfirmed"
ActiveSheet.Range("$A$13:$AA$2758").AutoFilter Field:=27, Criteria1:=">=" & DateSerial(2022, 1, 1), Operator:=xlAnd, Criteria2:="<=" & Date - 5
ActiveSheet.Range("$A$12:$AA$2758").AutoFilter Field:=25, Criteria1:= _
"<=" & DateSerial(2022, 12, 30)
End Sub
Could anyone point out my error?
Thanks.
Dec 20 2022 04:44 AM
AutoFilter does not sort data but filters them, i.e. it hides all rows that don't meet the specified criteria.
Try this:
Sub Sorter_Dato()
Range("A13:AA2758").Sort _
Key1:=Range("Y13"), _
Key2:=Range("AA13"), _
Key3:=Range("Z13"), _
Header:=xlYes
End Sub
Dec 20 2022 04:59 AM
Dec 20 2022 06:18 AM
Could you attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar?
Dec 20 2022 11:58 PM
Dec 21 2022 12:42 AM
I repeat the request in my previous reply.