airforceone
Board Regular
- Joined
- Feb 14, 2022
- Messages
- 190
- Office Version
- 2019
- 2016
- Platform
- Windows
good day mate,
need some guidance again, my code do run when not filtering between dates! but when I include the Date Covered in the range it does not show/filter intended record(s).
need some guidance again, my code do run when not filtering between dates! but when I include the Date Covered in the range it does not show/filter intended record(s).
VBA Code:
Sub AutoFilterDate()
Dim sDate As Long
Dim eDate As Long
sDate = Range("H1").Value
eDate = Range("I1").Value
ActiveSheet.AutoFilterMode = False
With Sheet10
If Not .AutoFilterMode Then .Range("A1").AutoFilter
.Range("A1").AutoFilter Field:=2, Criteria1:=">=" & sDate, Operator:=xlAnd, Criteria2:="<=" & eDate, Operator:=xlAnd ' This is where the issue is
.Range("C1").AutoFilter Field:=3, Criteria1:="Bob", Operator:=xlAnd
.Range("C1").AutoFilter Field:=4, Criteria1:="<50"
End With
End Sub
2024.07 - XL2BB Record.xlsm | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | |||
1 | Date | Item | Sales Rep | Quantity | Price | Commission | 2024.01.01 | 2024.03.01 | |||
2 | 2024.01.08 | Projector | Bob | 5 | 1,000.00 | 5% | |||||
3 | 2024.02.08 | Printer | Mark | 3 | 800.00 | 10% | |||||
4 | 2024.03.08 | White Board | Stacey | 10 | 900.00 | 6% | |||||
5 | 2024.04.08 | Printer | Mark | 15 | 500.00 | 10% | |||||
6 | 2024.05.08 | White Board | Bob | 20 | 600.00 | 15% | |||||
7 | 2024.06.08 | Projector | Stacey | 25 | 700.00 | 10% | |||||
8 | 2024.07.08 | White Board | Bob | 50 | 400.00 | 3% | |||||
9 | 2024.01.01 | White Board | Bob | 100 | 200.00 | 5% | |||||
10 | 2024.06.01 | White Board | Stacey | 2 | 300.00 | 6% | |||||
11 | 2024.06.01 | Printer | Stacey | 5 | 200.00 | 10% | |||||
12 | 2024.03.01 | Printer | Stacey | 40 | 100.00 | 5% | |||||
13 | 2024.03.01 | Printer | Stacey | 50 | 200.00 | 10% | |||||
14 | 2024.05.01 | Projector | Bob | 50 | 300.00 | 20% | |||||
15 | 2024.04.01 | Projector | Mark | 30 | 500.00 | 15% | |||||
TestData |