View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
pgarcia pgarcia is offline
external usenet poster
 
Posts: 304
Default Batch Delete VB code

I found the following code. Does any one know if this will run through the
sub folders? I have around 200 folder and need to delete .m4a files. Thanks

Sub test()
MyPath = "C:\Documents and Settings\My Documents\My Music"
Set fs = CreateObject("Scripting.FileSystemObject")

LastRow = Range("A1").End(xlDown).Row

For r = 2 To LastRow
fs.DeleteFile MyPath & Cells(r, "A").Value
Cells(r, "A").ClearContents ' Remove file from list after deleting it
Next

End Sub