I want to look and see if a file exists (based on a date entered into an input box). If the file exists, I want to delete the file. If the file does not exist, I want the macro to move onto the next line without an error message.
The code below works when the file exists but gets stuck on the " Kill ("C:\Users\smakatura\Documents\call report\" & tmpdate & " tmp.csv")" when the file does not exist.
What would be the proper coding to accomplish my goal?
The code below works when the file exists but gets stuck on the " Kill ("C:\Users\smakatura\Documents\call report\" & tmpdate & " tmp.csv")" when the file does not exist.
What would be the proper coding to accomplish my goal?
HTML:
Dim tmpdate As String
tmpdate = InputBox("Enter TMP Date")
'
If Len("C:\Users\smakatura\Documents\call report\" & tmpdate & " tmp.csv") <> 0 Then
Kill ("C:\Users\smakatura\Documents\call report\" & tmpdate & " tmp.csv")
End If
On Error Resume Next
Workbooks.Open filename:= _
"C:\Users\smakatura\Documents\call report\book2.xlsx"
Last edited: