+ Reply to Thread
Results 1 to 8 of 8

Copy multiple files to multiple locations

  1. #1
    Registered User
    Join Date
    09-03-2015
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    4

    Question Copy multiple files to multiple locations

    Hi,

    This is my first post to this forum.

    I'm trying to work out a script to copy thousands of files from a single (or multiple but it's easy enough to consolidate them) source to specified destination for each row.
    Each row contains Columns A:Destination File Path | B:File name |(Optional C:Source File Path)

    I came across this thread to move multiple files in a range however it assumes moving all file to a single destination.
    http://www.excelforum.com/excel-prog...ml#post4126148

    Any help would be very gretaly appreciated.

    Damien Cassidy

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,617

    Re: Copy multiple files to multiple locations

    The one from cited thread seems to be "almost ready" for you:

    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    09-03-2015
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    4

    Re: Copy multiple files to multiple locations

    Hi Kaper,

    Thanks for the response. I'm getting an error where it appears the destination path and file name aren't be defined.

    "Copy Error: E:\File Copy Test Source\Testfile1.txt to: \"

    This is my test (with both yours and my code)

    FilecopierTest.xlsm

    ...which looks like this:
    Destination Path Filename Source Path
    E:\File Copy Test Destinations\Dest 1 Testfile1.txt E:\File Copy Test Source
    E:\File Copy Test Destinations\Dest 2 Testfile2.txt E:\File Copy Test Source
    E:\File Copy Test Destinations\Dest 3 Testfile3.txt E:\File Copy Test Source

    I don't need to rename the files, just copy them. I modified the code as below but get the same error.
    I'm very new to this VBA stuff so I've laid it out step by step. I can't work out why the source path works but the destination doesn't when it's essentially the same thing. .

    Any further insights would be very greatly appreciated.

    Please Login or Register  to view this content.
    Kind regards,

    Damien

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,617

    Re: Copy multiple files to multiple locations

    Hi Damien,
    And what is the name of source file?

  5. #5
    Registered User
    Join Date
    09-03-2015
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    4

    Re: Copy multiple files to multiple locations

    Hi Kaper,

    Sorry for the slow reply. This is a work thing and I just enjoyed a long weekend.

    In my reply I mentioned that I don't need to change the filename. Having said that, there's plenty of potential scenarios where I would so I'm happy for a solution that does.

    I don't see why it would matter but FYI: The spreadsheet is not saved in the same location (or drive) as the source files.

    Regards,
    Damien

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,617

    Re: Copy multiple files to multiple locations

    So ... the file where macro is located is the source?
    anyway ... in the code yiu have 4 variabeles

    src
    fl
    dst
    rfl

    use them to achieve your goal (2 first determine "from where" and 2 last determine "copy to" location and name).

  7. #7
    Registered User
    Join Date
    09-03-2015
    Location
    Sydney, Australia
    MS-Off Ver
    2013
    Posts
    4

    Re: Copy multiple files to multiple locations

    Hi,

    I have updated the script to include optional variable source path and optional variable destination file name. I've renamed the variables to match.

    Column A: Source Path (will use last known value if blank - first entry (A2) must have a value
    Column B: Source Filename (must have a value)
    Column C: Destination Path (must have a value)
    Column D: Destination Filename (will use source filename if blank)

    Here's the code:

    Please Login or Register  to view this content.
    Thanks for your help Kaper.
    The next step is for it to create the destination path if it doesn't exist...

    Regards,
    Damien

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,617

    Re: Copy multiple files to multiple locations


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Most efficient way to copy multiple variables to specific cell locations using offset
    By joshnathan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2014, 07:18 AM
  2. Copy sheets from multiple CSV files to multiple workbooks that already exist
    By Mathual Jr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2013, 08:24 AM
  3. Need to import multiple text files from different locations
    By mattieb81 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2013, 06:18 AM
  4. [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
  5. Importing multiple text files from referenced locations
    By brisjast in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-25-2011, 08:37 AM
  6. Replies: 4
    Last Post: 08-02-2010, 07:16 AM
  7. [SOLVED] How to? Copy from one location to multiple locations (easy)?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2006, 09:45 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