Remove All files from Folder with VBA

In this article I will show you how to remove all of the files in a folder with the use of VBA.  It is a very handy tool to have at your disposal if you want to avoid the manual task of deleting a folder, creating a new folder and renaming that folder.  The following will simply delete a folders contents so it is ready for new contents to be added.

The following is the procedure to create a new sheet with the data that relates to that sheet from a master worksheet.  

Option Explicit Sub RemFolderData() 'Remove contents of folder regardless of extension with Excel VBA
Kill "C:\Users\HYMC\Downloads\Test\*.*"
End Sub

It is a very simple procedure so I will not attach a file.Be sure to get the file path correct and have the extension back slash \ at the end of your file path.

It might be an idea to have a message box asking if you actually want to delete the folder because after it is done the action can not be undone.

Sub RemFolderData2() 'Remove contents of folder regardless of extension with Excel VBA
Dim Msg as String
Msg=MsgBox("Delete Folder", vbYesNo)

If Msg=vbYes Then Kill "C:\Users\HYMC\Downloads\Test\*.*"
End Sub

The above VBA procedure should work nicely in your Excel file.