View Full Version : Delete File if the specific cell is empty

10-15-2015, 09:14 AM
Hello you all,

I don't know it this is possible but I hope I can get a answer to this question :)
Ok so basically I have a whole folder with files on which my macro has to run. One step of my macro is to filter dates and sometimes after filtering there is no data left, so if this is the case I want to delete the file and then move on to the next one. But I don't know if this is possible.
So I thought starting with this:

If WorksheetFunction.CountA(Range("A2")) = 0
With ThisWorkbook
.Saved = True
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
End Select

Not sure if this is working. Hope somebody can help me. Thank you