AlanElston icon

Trashit

AlanElston | PRO | 01/20/21 11:10:21 AM UTC | 0 โญ | 7181 ๐Ÿ‘๏ธ | Never โฐ | []
VisualBasic |

770 B

|

None

|

0 ๐Ÿ‘

/

0 ๐Ÿ‘Ž

' ย  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
ย 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    ๐Ÿ‘

    /

    ๐Ÿ‘Ž

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    ๐Ÿ‘

    /

    ๐Ÿ‘Ž

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    ๐Ÿ‘

    /

    ๐Ÿ‘Ž