Find File Name and Delete
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.
|