+ Reply to Thread
Results 1 to 4 of 4

Move open workbook to different folder based on the value of a certain cell

  1. #1
    Registered User
    Join Date
    03-17-2014
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2013
    Posts
    22

    Move open workbook to different folder based on the value of a certain cell

    I feel like, I have tried everything to make it work with the functions: Name / FileCopy / Kill
    I can't make it work..

    I have a bunch of excel files. I want to make a macro in each of them, where you can change the status of the workbook from f.i. "Active case" to "Order".
    Based on the change in status, the file should be moved to a different folder.

    If you can't base a macro on the change of a cell value, it's fine with a button as well - the problem is, how do I move it with a macro?

    I think the reason, why I haven't been able to make it work, is because the macro is in the open workbook that is supposed to be moved.

    Does anyone know of a solution to this problem?
    Last edited by mikkelsl; 09-13-2014 at 08:10 AM.

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Move open workbook to different folder based on the value of a certain cell

    use worksheet_change event to run macro when cell value change.
    1. get the full name i.e. path & name of the open workbook in a variable
    2. save as the workbook to new location. now the open workbook is the one at the new location
    3. delete (kill) the old file (full name already stored in variable)
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Move open workbook to different folder based on the value of a certain cell

    deleted double post
    Last edited by buran; 09-13-2014 at 08:31 AM.

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Move open workbook to different folder based on the value of a certain cell

    I think the reason, why I haven't been able to make it work, is because the macro is in the open workbook that is supposed to be moved.
    That is correct. When a file is open in Microsoft Office, the file cannot be deleted or moved.

    I want to make a macro in each of them, where you can change the status of the workbook from f.i. "Active case" to "Order". Based on the change in status, the file should be moved to a different folder.
    You can solve your problem the way buran suggested, which is a sound method that will work effectively.

    Alternatively, you can change your software design to run your macros from a Master Workbook that has no data. It can change the status in your data files, open and close the data files, and move the files to the proper folder.

    Lewis

  5. #5
    Registered User
    Join Date
    03-17-2014
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Move open workbook to different folder based on the value of a certain cell

    Hi buran and LJMetzger, thanks for your answers.

    That's exactly what I've been trying to do actually, but I can't make it work. If you can see, where I'm mistaken, please let me know.

    Please Login or Register  to view this content.

+ 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] Button to open folder based on cell hyperlink adress
    By mirenoba in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-11-2014, 05:39 AM
  2. VBA to open folder on the network based on data from the active cell
    By s0o0y in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2013, 04:38 PM
  3. Replies: 1
    Last Post: 01-10-2013, 08:22 AM
  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. Open multiple files from a folder based on cell information?
    By bshape1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-03-2008, 07:55 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