Hi Ron
I want to copy all Excel files from folder C:\pull as well as the excel files in the sub-directories within the pull directory for eg C:\pull\br1 , C:\pull\BR2 etc to C:\summary profits
I have used your code below, but when running the macro , it comes up with message "Path now found and the following code iis highlighted
FSO.CopyFolder Source:=FromPath, Destination:=ToPath
It would be appreciated if you could assist in resolving the problem
Sub Copy_Certain_Files_In_Folder()
'This example copy all Excel files from FromPath to ToPath.
'Note: If the files in ToPath already exist it will overwrite
'existing files in this folder
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FileExt As String
FromPath = "C:\pull" '<< Change
ToPath = "C:\summary profits" '<< Change"
FileExt = "*.xls" '<< Change
'You can use *.* for all files or *.doc for Word files
If Right(FromPath, 1) <> "\" Then
FromPath = FromPath & "\"
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " doesn't exist"
Exit Sub
End If
FSO.CopyFolder Source:=FromPath, Destination:=ToPath
MsgBox "You can find the files and subfolders from " & FromPath & " in " & ToPath
End Sub