Results 1 to 5 of 5

Help Copy files from one folder and subfolders to another based on a list in Excel

Threaded View

  1. #1
    Registered User
    Join Date
    09-30-2019
    Location
    London
    MS-Off Ver
    16
    Posts
    3

    Help Copy files from one folder and subfolders to another based on a list in Excel

    At the moment I'm using the following code and work perfectly on just folder any idea how to make it search also in a subfolder within the folder
    Many Thanks
    Sub copyfiles()
    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 Leith Ross; 09-30-2019 at 01:12 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] list of subfolders in folder - without files and sub-subfolders
    By MartyZ in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2022, 10:56 AM
  2. VBA Copy specific files listed in Excel from folder & subfolders to another folder - FSO
    By HelloFriends in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-03-2019, 02:55 PM
  3. Copy Files from One Folder to Another Folder based on a List In Excel
    By civram1982 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-21-2019, 06:34 AM
  4. Copy specific files from subfolders to new folder
    By dxl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-28-2016, 06:06 PM
  5. List of files in selected folder and subfolders
    By Un-Do Re-Do in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-09-2015, 04:52 AM
  6. list subfolders and files of main folder with details
    By buerere in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-21-2014, 10:44 AM
  7. Needs macro to copy excel files from folders, subfolders to new folder
    By genetist in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2014, 08:53 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1