VBA DeleteFolder

The FileSystemObject VBA DeleteFolder function deletes a specified folder or folders.

VBA DeleteFolder Syntax

fso.DeleteFolder( foldername, [ force ] )

foldername
The location names of folder(s) to delete. You can use wildcards such as *.* to specify more than a single folder matching the pattern.
force
Optional. If True only read-only folders are deleted. If False any folders are deleted. False is default.

VBA DeleteFolder Examples

Set fso = CreateObject("Scripting.FileSystemObject")

'Delete specified folder
fso.DeleteFolder "C:\Src"

'Delete all Sub Subfolders within the C:\Src folder
fso.DeleteFolder "C:\Src\*\Sub"

'Delete all subfolders
fso.DeleteFolder "C:\Src\*"