Hi friends,

I want to filter the data by date.
The start date is on ‘Search’ sheet range B3
The end date is on ‘Search’ sheet range C3
I’m not getting output from the following code. If I remove the conditions for date ‘Search’ sheet then it works but error in save as code.
Option explicit

Sub DateFilter()

If Sheets("Search").Range("B3").Value = "" Then
MsgBox "Please enter start date", 64
Exit Sub
End If

If Sheets("Search").Range("C3").Value = "" Then
MsgBox "Please enter end date", 64
Exit Sub
End If

If Sheets("Search").Range("B3").Value > Sheets("Search").Range("C3").Value Then
MsgBox "Sorry! The start date must be < end date.", 64
Exit Sub
End If

Application.ScreenUpdating = False

With Sheets("Data")
.Range("A1:P1").AutoFilter Field:=2, Criteria1:=">=" & Format(Sheets("Search").Range("B3").Value, "mm/dd/yyyy") _
, Operator:=xlAnd, Criteria2:="<=" & Format(Sheets("Search").Range("C3").Value, "mm/dd/yyyy")
    Range("B1:D1000, G1:G1000").SpecialCells(xlCellTypeVisible).Copy
End With
Workbooks.Add
Range("B4").PasteSpecial xlPasteValues: Range("B4").PasteSpecial Paste:=xlPasteFormats
Application.DisplayAlerts = False
'ActiveWorkbook.SaveAs ("ThisWorkbook.Path & "\OUTPUT\my information " & Format(Date, "DD-MMM-YYYY") & ".xlsx")
            ActiveWindow.DisplayGridlines = False
ActiveWindow.Close
Sheets("Data").AutoFilterMode = False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "done"
End Sub
Any help will be highly appreciated.

Thanking you in anticipation.