Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Get the List of All Sub folders in a Folder


This following code allows you to retrieve the sub folder names inside the folder.

' Add Reference to Microsoft Scripting Runtime

Sub GetSubFolderNames()
Dim MyFSO As FileSystemObject
Dim MyFile As File
Dim MyFolder As Folder
Dim MySubFolder As Folder

Set MyFSO = New Scripting.FileSystemObject
Set MyFolder = MyFSO.GetFolder("C:\Desktop\Test")

For Each MySubFolder In MyFolder.SubFolders
    Debug.Print MySubFolder.Name
Next MySubFolder

End Sub

Subscribe

Enter your e-mail below and get notified on the latest blog posts.




Tags

VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts


Follow Us