Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' https://www.myonlinetraininghub.com/excel-forum/vba-macros/delete-specific-files-in-a-folder
- Sub Trashit()
- Rem 1 Workbooks info
- Const Ext As String = "xlsx"
- Const FldrPth As String = "C:\BookData\AR"
- 'Dim FldrPth As String: Let FldrPth = ThisWorkbook.path ' can be used if macro is in file in same filder as files to be killded
- Dim arrNms() As Variant: Let arrNms() = Array("Sheet2", "DCH") ' <--- This can it be also be got from other lists programatically maybe
- Rem 2 Do it
- Dim StearIsIt As Variant ' For each of it is in Variant type
- For Each StearIsIt In arrNms()
- If Len(Dir(FldrPth & Application.PathSeparator & StearIsIt & "." & Ext & "", vbNormal)) > 0 Then Kill FldrPth & Application.PathSeparator & StearIsIt & "." & Ext
- Next StearIsIt
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement