+ Reply to Thread
Results 1 to 12 of 12

Excel VBA Script to Move files from one folder to another based on data in three columns

  1. #1
    Registered User
    Join Date
    10-29-2013
    Location
    US
    MS-Off Ver
    Excel 2013
    Posts
    6

    Excel VBA Script to Move files from one folder to another based on data in three columns

    I need help with creating a script that will take the data from an excel file and use it to transfer files from one folder to another.

    Column A will be the current directory
    Column B will be the File name
    Column C will be the new directory

    There will be 10,000+ rows.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Excel VBA Script to Move files from one folder to another based on data in three colum

    Please Login or Register  to view this content.
    I think, it's a while since I've written that sort of code.

    Assumes your directory includes the "\" at the end and that your filename includes the extension and that the destination folder exists.

  3. #3
    Registered User
    Join Date
    10-29-2013
    Location
    US
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Excel VBA Script to Move files from one folder to another based on data in three colum

    It is giving me an error that "File already exists", but the destination folder (Column C) is empty.

    Donne

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Excel VBA Script to Move files from one folder to another based on data in three colum

    try:
    Please Login or Register  to view this content.
    instead

  5. #5
    Registered User
    Join Date
    10-29-2013
    Location
    US
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Excel VBA Script to Move files from one folder to another based on data in three colum

    It says "syntax error"

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Excel VBA Script to Move files from one folder to another based on data in three colum

    Sorry about this, will get there in the end:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    10-29-2013
    Location
    US
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Excel VBA Script to Move files from one folder to another based on data in three colum

    It says Runtime Error 58 - File Already Exists

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Excel VBA Script to Move files from one folder to another based on data in three colum

    Pretty sure the file you are trying to move already exists then...
    Can you upload a workbook with an example of the data in A, B and C columns, click go advanced and then attachments.

  9. #9
    Registered User
    Join Date
    10-29-2013
    Location
    US
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Excel VBA Script to Move files from one folder to another based on data in three colum

    I have attached the Excel file.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Excel VBA Script to Move files from one folder to another based on data in three colum

    I tried this on your example data and it worked ok:
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    10-29-2013
    Location
    US
    MS-Off Ver
    Excel 2013
    Posts
    6

    Re: Excel VBA Script to Move files from one folder to another based on data in three colum

    Perfect. Thank you so much!

    Can I use similar logic to rename a file?

  12. #12
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Excel VBA Script to Move files from one folder to another based on data in three colum

    to rename a file you would need:
    fs.getfile("C:\example.xls").name = "C:\renamedexample.xls"

+ 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. Replies: 1
    Last Post: 01-28-2019, 06:55 PM
  2. Macro - move files to folder based on list in worksheet
    By uncleslinky in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-03-2015, 05:57 PM
  3. move files to folder based on a .igy list
    By henkdevreisch in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-14-2013, 01:42 PM
  4. move files from 1 folder to another based on cell values
    By aravindhan_31 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2010, 01:03 PM
  5. vba script to generate files based on an data from an Excel sheet
    By bananas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-30-2007, 03:00 PM

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