Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find File Name and Delete | Excel Programming | |||
Find File Name and Delete | Excel Programming | |||
Function to read text file; find string; delete same before import | Excel Programming | |||
Find and Replace - delete the remainder of the text in the cell after my Find | Excel Programming | |||
Can't find macro in an Excel file to delete it | Excel Discussion (Misc queries) |