Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default 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 ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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 ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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 ***



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Delete file if file exists.

Thanks...both work perfect. I appreciate it immensly.
-Mike



*** Sent via Developersdex http://www.developersdex.com ***
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Exists Mike McLellan Excel Discussion (Misc queries) 2 May 4th 06 09:20 AM
File Exists Pflugs Excel Programming 2 September 4th 05 07:05 AM
IF File Exists [email protected] Excel Programming 1 November 22nd 04 07:24 PM
File already exists Michael Malinsky[_3_] Excel Programming 0 June 28th 04 08:02 PM
the file already exists - do you want to replace the existing file? Paul James[_3_] Excel Programming 4 December 12th 03 02:50 AM


All times are GMT +1. The time now is 12:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"