'Dir(strfpath)' is going to return a string value of the filename or an empty string so if true/false condition is ging to cause an error.
Need to check for a string value.
If Dir(strfpath) <> "" Then Kill strfpath
or you could use this variation
If Not Dir(strfpath) = "" Then kill strfpath
another way is to use a function like:
Sub killFile()
Dim strfpath As String
strfpath = "c:\" & Range("C1").Value & ".xls"
If FileExists(strfpath) Then
Kill strfpath
Debug.Print "Killed the File " & Range("C1").Value & ".xls"
End If
End Sub
Private Function FileExists(fname) As Boolean
' Returns TRUE if the file exists
Dim x As String
x = Dir(fname)
If x <> "" Then FileExists = True _
Else FileExists = False
End Function