ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete file if file exists. (https://www.excelbanter.com/excel-programming/340466-delete-file-if-file-exists.html)

Michael Smith

Delete file if file exists.
 
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




*** Sent via Developersdex http://www.developersdex.com ***

Tom Ogilvy

Delete file if file exists.
 
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

--
Regards,
Tom Ogilvy

"Michael Smith" wrote in message
...
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




*** Sent via Developersdex http://www.developersdex.com ***




Bob Phillips[_6_]

Delete file if file exists.
 
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

--
HTH

Bob Phillips

"Michael Smith" wrote in message
...
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




*** Sent via Developersdex http://www.developersdex.com ***




Michael Smith

Delete file if file exists.
 
Thanks...both work perfect. I appreciate it immensly.
-Mike



*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 05:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com