• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy folders to desktop

Hi,

I have about 100 folder with multiple sub-folders.

I want to copy one specific sub-folder named "billing" from all the folders.

Is there any macro i can run ?

Thanks
 
Thanks !

This doesn't resolve my issue. I need to copy the sub-folder from all the main folders not the files directly. As copying the files means I have to copy the files in separate sub-folders again. Any advice ?
 
Try This!

Code:
Public searchFolderName As String
Sub findFolder()
   
    searchFolderName = "F:\"

    Dim FileSystem As Object

    Set FileSystem = CreateObject("Scripting.FileSystemObject")

    doFolder FileSystem.getFolder(searchFolderName)


End Sub

Sub doFolder(Folder)
    Dim subFolder
    On Error Resume Next
    For Each subFolder In Folder.subfolders
        If Split(subFolder, "\")(UBound(Split(subFolder, "\"))) = "MONTY" Then
            MsgBox "gotcha"
            subFolder.CopyFolder Source:=searchFolderName, Destination:="C:\Users\MONTY\Desktop\"
        End
        End If

        doFolder subFolder
    Next subFolder

End Sub
 
Back
Top