I am accepting a date from Input Box and filtering my data and saving it in a new workbook. When I am saving this new workbook, its giving me a Run-time error 1004 with a sentence as:
Method 'SaveAs'of object'_Workbook' failed.
I am unable to find a solution to this.
Sub GIACTSDS121()
Dim dte As Date
mBox = InputBox("Enter a date")
If IsDate(mBox) Then
dte = CDate(mBox)
Dim Lastrow As Long
Lastrow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
ActiveSheet.Range("A1:AC" & Lastrow).AutoFilter Field:=2, Criteria1:=">=" & dte, _
Operator:=xlAnd, Criteria2:="<" & dte + 1
Range("U1").Select
ActiveSheet.Range("A1:AC" & Lastrow).AutoFilter Field:=21, Criteria1:="Yes"
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
ActiveSheet.Range("A:A,E:E,I:I,M:N,Q:T,X:Z").EntireColumn.Delete
ActiveWorkbook.SaveAs Filename:="K:\K_Drive\RP\RPS-Metrics-ops\' Operations Metrics\Investigation Documentation\GIACT Investigations\SDS_Cases\_" & dte & ".xlsx", FileFormat:=51
ActiveWorkbook.Close
Else
MsgBox "This is not a date. Please try again"
End If
End Sub