Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Find File Name and Delete

I have an excel document that has two columns: A=Folder/Path, B=Filename. I
plan to add a yes/no validation list to column C. I need to write a macro so
that if column C = Yes, Go to Folder/Path/Filename and delete that file. Is
that even possible? Any help is greatly appreciated. I have about 10,000
files that need to be deleted.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Find File Name and Delete

It works. Thanks so much for your help!

"PJFry" wrote:

I scratched this out.

Sub KillFiles()

Dim fPath As Range
Dim fName As Range
Dim fDelete As Range

Set fPath = Sheet1.Range("A2")
Set fName = fPath.Offset(0, 1)
Set fDelete = fPath.Offset(0, 2)

Do Until IsEmpty(fPath)

If Dir(fPath & "\" & fName) < "" And fDelete = "Yes" Then
Kill fPath & "\" & fName

Set fPath = fPath.Offset(1, 0)
Set fName = fName.Offset(1, 0)
Set fDelete = fDelete.Offset(1, 0)
Else
Set fPath = fPath.Offset(1, 0)
Set fName = fName.Offset(1, 0)
Set fDelete = fDelete.Offset(1, 0)
End If

Loop

End Sub

I'd test it on a sample file and directory first.
--
Regards,

PJ
Please rate this post using the vote buttons if it was helpful.



"mrsviqt" wrote:

I have an excel document that has two columns: A=Folder/Path, B=Filename. I
plan to add a yes/no validation list to column C. I need to write a macro so
that if column C = Yes, Go to Folder/Path/Filename and delete that file. Is
that even possible? Any help is greatly appreciated. I have about 10,000
files that need to be deleted.

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
Find File Name and Delete PJFry Excel Programming 0 April 28th 09 11:21 PM
Find File Name and Delete Don Guillett Excel Programming 0 April 28th 09 11:13 PM
Function to read text file; find string; delete same before import [email protected] Excel Programming 32 August 5th 08 10:50 PM
Find and Replace - delete the remainder of the text in the cell after my Find [email protected] Excel Programming 4 August 4th 07 03:39 AM
Can't find macro in an Excel file to delete it Ron Excel Discussion (Misc queries) 3 July 1st 05 01:07 PM


All times are GMT +1. The time now is 02:50 PM.

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

About Us

"It's about Microsoft Excel"