+ Reply to Thread
Results 1 to 10 of 10

Move files from one directory to another based on excel data

  1. #1
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    Move files from one directory to another based on excel data

    I need help coding this.

    I've got a sheet with document file names (column G), the current directory (column H) and the future directory (column I). The future directories have already been created in a previous operation. The spreadsheet is located in the same place as the other folders.

    It's something similar to this: http://www.excelforum.com/excel-gene...xcel-data.html

    Can anyone help with this please? My VBA knowledge is just beginning.

    Thanks!

    Chris
    Last edited by CWinkler; 04-28-2011 at 10:17 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Move files from one directory to another based on excel data

    Hello Chris,

    Welcome to the Forum!

    The macro below will start in cell "G1" and go down to the last entry (file name) in that column. You can change "G1" to another cell if you want.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Move files from one directory to another based on excel data

    Thanks for the quick response.

    I executed it, but I'm getting a Run-time Error '53': File Not found:

    Please Login or Register  to view this content.
    I figure I should mention that the destination folder has a space, it's usually something along the lines of "CN 12345"
    Last edited by CWinkler; 04-28-2011 at 05:31 PM.

  4. #4
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Move files from one directory to another based on excel data

    I think you might have mispelled Range in there
    Please Login or Register  to view this content.
    I fixed the error when I ran it. Still does not work.
    Please Login or Register  to view this content.
    Last edited by CWinkler; 04-28-2011 at 06:39 PM. Reason: clarification

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Move files from one directory to another based on excel data

    Hello CWinkler,

    Nice catch on my typo. Sorry about that. Glad you got it to work.

  6. #6
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Move files from one directory to another based on excel data

    Unfortunately, I did not get it to work. Sorry, my posts were a bit cryptic. Office is crazy today.

    The runtime error is still present.
    Last edited by CWinkler; 04-28-2011 at 08:09 PM. Reason: clarification

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Move files from one directory to another based on excel data

    Hello CWinkler,

    I think the back slashes are missing between the file path and file name.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Move files from one directory to another based on excel data

    No dice. Still same runtime bug.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Move files from one directory to another based on excel data

    Hello CWinkler,

    This statement should work in Excel 2007. Are you providing the full path for the current directory? What error are you getting now?

  10. #10
    Registered User
    Join Date
    04-28-2011
    Location
    Oshkosh, Wi
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Move files from one directory to another based on excel data

    Double-checked this against new files and folders. It worked! The excel column for Filepath and NewPath must contain the entire path of the files, not just the folder name in the same directory as the excel.

    ie:
    D:/Folder/Filepath
    instead of just
    Filepath

    Is there a way to make it copy files to the destination rather than just relocate them?

    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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