alantse2010
New Member
- Joined
- Jun 9, 2018
- Messages
- 34
- Office Version
- 365
- 2019
- 2016
- 2010
- Platform
- Windows
Hello, i want to filter the data between Date - 3 to Date +3, i am trying to format the date in code but not working, it return no result.
Here is my expected result:
https://imgur.com/a/83jTSTX
Please help me.
Thank you very much.
Here is my expected result:
https://imgur.com/a/83jTSTX
Please help me.
Thank you very much.
Code:
Private Sub CommandButton17_Click()
Dim today, startdate, enddate As Date
Dim startdate2, enddate2 As String
today = Date
startdate = Date - 3
enddate = Date + 3
startdate2 = Format(Date - 3, "dd/mm/yyyy")
enddate2 = Format(Date + 3, "dd/mm/yyyy")
Application.ScreenUpdating = False
Set wSheetStart = ThisWorkbook.Sheets("A2")
wSheetStart.Activate
wSheetStart.AutoFilterMode = False
ActiveSheet.Range("A6:AC6").AutoFilter Field:=1, Criteria1:=">=" & startdate2, Operator:=xlAnd, Criteria2:="<=" & enddate2
ActiveSheet.Range("A777").Select