I have the following code to delete specified files in a folder
I have set up the Folder Path in A2, No for subfolder in B2 and *EMTQ* in C2 for file name
I get subscript out of range when running macro and code below is highlighted
It would be appreciated if someone could kindly amend my code
Code:
Sub Delete_Files()
mypath = Sheets("Delete Old EMTQ Files").Range("A2") & "\"
On Error Resume Next
For Each cl In Sheets("Delete Old EMTQ Files").Range("C2", Sheet1.Range("C" & Sheets("Delete Old EMTQ Files").Rows.Count).End(xlUp))
With CreateObject("Scripting.filesystemObject")
For Each sf In .GetFolder(mypath).Files
If UCase(sf.Name) Like "*" & UCase(cl.Value) & "*" Then Kill sf
Next
End With
Next
End Sub
I have set up the Folder Path in A2, No for subfolder in B2 and *EMTQ* in C2 for file name
I get subscript out of range when running macro and code below is highlighted
Code:
mypath = Sheets("Delete Old EMTQ Files").Range("A2") & "\"
It would be appreciated if someone could kindly amend my code