Afternoon,
I am attempting to copy multiple files from multiple folders into one folder. I have a macro that allows me to do this from one folder to the target folder, but each time I use the macro, I have to manually select the folder for that file name, and then manually select the target file. I am looking to bypass this as I will have to update the files weekly and I have over 400 folders to go through.
Example:
Location: Folder #1
File: 01 Work Order
Location: Folder #2
File: 02 Work Order
I want to copy file "01 Work Order" and file "02 Work Order" from their respective folders to a separate folder. The current macro I am using is written as such:
If more information is needed, let me know, and i'll try to grab pictures of what I want to do. Thanks!
~Mslduth
I am attempting to copy multiple files from multiple folders into one folder. I have a macro that allows me to do this from one folder to the target folder, but each time I use the macro, I have to manually select the folder for that file name, and then manually select the target file. I am looking to bypass this as I will have to update the files weekly and I have over 400 folders to go through.
Example:
Location: Folder #1
File: 01 Work Order
Location: Folder #2
File: 02 Work Order
I want to copy file "01 Work Order" and file "02 Work Order" from their respective folders to a separate folder. The current macro I am using is written as such:
Sub copyfiles()'Updateby Extendoffice
Dim xRg As Range, xCell As Range
Dim xSFileDlg As FileDialog, xDFileDlg As FileDialog
Dim xSPathStr As Variant, xDPathStr As Variant
Dim xVal As String
On Error Resume Next
Set xRg = Application.InputBox("Please select the file names:", "KuTools For Excel", ActiveWindow.RangeSelection.Address, , , , , 8)
If xRg Is Nothing Then Exit Sub
Set xSFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xSFileDlg.Title = "Please select the original folder:"
If xSFileDlg.Show <> -1 Then Exit Sub
xSPathStr = xSFileDlg.SelectedItems.Item(1) & ""
Set xDFileDlg = Application.FileDialog(msoFileDialogFolderPicker)
xDFileDlg.Title = "Please select the destination folder:"
If xDFileDlg.Show <> -1 Then Exit Sub
xDPathStr = xDFileDlg.SelectedItems.Item(1) & ""
For Each xCell In xRg
xVal = xCell.Value
If TypeName(xVal) = "String" And xVal <> "" Then
FileCopy xSPathStr & xVal, xDPathStr & xVal
End If
Next
End Sub
If more information is needed, let me know, and i'll try to grab pictures of what I want to do. Thanks!
~Mslduth