Results 1 to 3 of 3

Copy multiple files in different folders

Threaded View

  1. #1
    Registered User
    Join Date
    12-14-2016
    Location
    mumbai
    MS-Off Ver
    2010
    Posts
    3

    Post Copy multiple files in different folders

    Hell Everyone,

    I'm currently stuck on this VBA Code. What I'm trying to do is copy files in a directory using an Excel macro.

    For example, A2 is the source folder and B2 is the destination folder and C2 is the file name. The code that I use only work for the source & destination in the first column (i.e, the destination in B2 remains same for all the file names. The macro shared in the thread http://www.excelforum.com/showthread...13#post4542813 is for multiple files from one source folder to one destination folder. In my case source and destination folder change as per the list

    Sub TESCO()
    
    Dim src As String, dst As String, fl As String
        
        Dim lngMyRow As Long
        Dim lngLastRow As Long
        
        Application.ScreenUpdating = False
        
        lngLastRow = Range("A:B").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row + 1
        Range("G1") = lngLastRow
        Range("G2") = lngMyRow
        
        'Source directory
        src = Range("A2")
        
        'Destination directory
        dst = Range("C" & lngMyRow)
        
        For lngMyRow = 2 To lngLastRow
            'File name
            fl = Range("B" & lngMyRow)
            
            On Error Resume Next
                FileCopy src & "\" & fl, dst & "\" & fl
                
        Next lngMyRow
        
        Application.ScreenUpdating = True
        
        MsgBox "Done"
        
    End Sub
    Thanks and Regards!
    Last edited by payalvj; 12-15-2016 at 06:57 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Use Excel VBA to Copy multiple files to different folders
    By mm1234mail in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-25-2020, 09:55 AM
  2. Use Excel VBA to Copy multiple files from different source folders to different folders
    By mm1234mail in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2014, 01:17 PM
  3. How to copy and rename files in vba by searching multiple folders for files
    By razorace in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2014, 04:21 AM
  4. Replies: 1
    Last Post: 09-12-2013, 09:23 PM
  5. [SOLVED] Copy range from multiple files in multiple folders to single sheet in master WB
    By Royzer in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-18-2012, 03:40 PM
  6. Search Folders and Return Copy files matching multiple criteria
    By akq125 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-13-2012, 11:56 PM
  7. Copy multiple files from folders
    By jeff p in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-30-2009, 02:27 AM

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