Delete file if file exists.

M

Michael Smith

I have a file which I've listed paths of files in column "C". I need to
cycle through column C and delete the file if it exists, do nothing if
it doesn't exist.

TIA!
-Mike
 
T

Tom Ogilvy

Dim rng as Range, cell as Range
set rng = range(cells(1,3),cells(1,3).end(xldown))
for each cell in rng
if dir(cell) <> "" then
kill cell
end if
Next
 
B

Bob Phillips

On Error Resume Next
For i = 1 To Cells(Rows.Count,"C").End(xlUp).Row
Kill Cells(i,"C")
Next i
On Error Goto 0
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top