Im missing something here.
I would like to delete all *.xlsx files in this folder including all subfolders that might be in this folder.
I would like to delete all *.xlsx files in this folder including all subfolders that might be in this folder.
VBA Code:
Sub Clear_All_Files_And_SubFolders_In_Folder2()
'Delete all files and subfolders
'Be sure that no file is open in the folder
Dim fso As Object
Dim MyPath As String
Set fso = CreateObject("scripting.filesystemobject")
MyPath = "c:\tc" '<< Change
If Right(MyPath, 1) = "\" Then
MyPath = Left(MyPath, Len(MyPath) - 1)
End If
If fso.FolderExists(MyPath) = False Then
MsgBox MyPath & " doesn't exist"
Exit Sub
End If
On Error Resume Next
'Delete files
fso.DeleteFile MyPath & "\*.XLSX", True
'Delete subfolders
fso.deletefolder MyPath & "\*.XLSX", True
On Error GoTo 0
End Sub