I have setup up some files names with wilcards in Col O on sheet data
eg
The InterestXls.Xls is being deleted but nome of the eWhs*.* files eg eWhs_sales_Inquiry.xlsx, eWhs_sale_Inquiry (1).xlsx, eWhs_Statement_Inquiry.xlsx, eWhs_Statement_Inquiry (2).xlsx etc
It would be appreciated if someone could assist me
eg
eWhs*.* |
InterestXls.Xls |
The InterestXls.Xls is being deleted but nome of the eWhs*.* files eg eWhs_sales_Inquiry.xlsx, eWhs_sale_Inquiry (1).xlsx, eWhs_Statement_Inquiry.xlsx, eWhs_Statement_Inquiry (2).xlsx etc
Code:
Sub DeleteFiles()
Dim Filepath As String
Filepath = "C:\test"
Sheets("data import").Select
LR = Cells(Rows.Count, "O").End(xlUp).Row
For Each c In Range("O2:O" & LR)
If Len(c) > 0 Then
If Len(Dir(Filepath & "\" & c.Value)) > 0 Then
Kill Filepath & "\" & c.Value
End If
End If
Next
End Sub
It would be appreciated if someone could assist me