+ Reply to Thread
Results 1 to 7 of 7

Moving files to variable destination folders using Excel sheet and VBA

  1. #1
    Registered User
    Join Date
    11-27-2022
    Location
    Bruges, Belgium
    MS-Off Ver
    Version 2210
    Posts
    3

    Moving files to variable destination folders using Excel sheet and VBA

    Hello,

    I have a folder with 300+ pictures and an Excel-sheet with a column containing the current (source) folder and a column containing the destination folder that the files should move to.
    The destination folder is variable, the source folder is not.

    I've recreated my problem in a test case (see attached).
    My code sould read the column called "DestinationFolderFull" and move files accordingly.

    In other words:
    Picture_00001.jpg and Picture_00002.jpg should go to the folder named "map1".
    Picture_00003.jpg and Picture_00004.jpg should go to the folder named "map2", and so on.

    I've tried coding it using the FileSystemObject, but I'm having trouble with the VBA code reading the cells.
    How do I code this in VBA?

    Kind Regards,
    W.D.White
    Attached Files Attached Files
    Last edited by WalterD.White; 11-28-2022 at 09:01 AM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Moving files to variable destination folders using Excel sheet and VBA


    Hello,

    no need FSO for normal files so via the Name VBA statement, to see in VBA help …

  3. #3
    Registered User
    Join Date
    11-27-2022
    Location
    Bruges, Belgium
    MS-Off Ver
    Version 2210
    Posts
    3

    Re: Moving files to variable destination folders using Excel sheet and VBA

    Hello Marc,

    Thank you for your reply.
    I'm not sure I understand. I don't want to copy or rename a file, I want to move files.

    I was inspired to code this, based on "How To Copy Or Move Files From One Folder To Another Based On A List In Excel?" on the Extendoffice website.
    Sorry for not posting the URL, my account is new and it's blocking me.

    The only trouble is that you need to physically select the source and destination folders and I don't want that.
    The code should just read and input the destination folders automatically.

    Kind Regards,
    W.D.White

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Moving files to variable destination folders using Excel sheet and VBA


    Do not post a link of any procedure non matching your need !
    Just use the Name statement as designed for …

  5. #5
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,905

    Re: Moving files to variable destination folders using Excel sheet and VBA

    This should do it and put the result of the exercise in column G

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    11-27-2022
    Location
    Bruges, Belgium
    MS-Off Ver
    Version 2210
    Posts
    3

    Re: Moving files to variable destination folders using Excel sheet and VBA

    Thank you very much ByteMarks!
    This worked like a charm!

    Kind Regards,
    W.D.White

  7. #7
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,905

    Re: Moving files to variable destination folders using Excel sheet and VBA

    You're welcome.

+ 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. [SOLVED] Macro to convert all xls files to xlsx with moving the files into new folders
    By nettadecoco in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 12-29-2023, 02:34 PM
  2. [SOLVED] Move Files from Folders and Subfolders to Destination address given in Column C
    By Ravana in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2021, 02:36 AM
  3. Moving several sub folders to a new destination based on their names
    By nazaninibb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-11-2021, 01:47 AM
  4. Moving like named files into folders with same name
    By oybombadil in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-25-2015, 08:22 AM
  5. moving quarter files to folders
    By saratu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-25-2014, 11:55 AM
  6. Archiving Files - Creating New Folders and Moving Files
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2011, 06:47 AM
  7. Moving files between folders using VBA in Excel
    By Paul in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2005, 10:05 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