Hi All,
I found this sub routine online and it works fine.
My problem now is the files selected need to be extracted from a zip folder. Not all files in the zip folder need to be extracted just the ones selected in the original routine.
Is it possible to modify this to extract the files selected and copied to the new folder selected in initial routine.
Any help appreciated.
E
I found this sub routine online and it works fine.
My problem now is the files selected need to be extracted from a zip folder. Not all files in the zip folder need to be extracted just the ones selected in the original routine.
Is it possible to modify this to extract the files selected and copied to the new folder selected in initial routine.
Any help appreciated.
E
VBA Code:
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
Last edited by a moderator: