+ Reply to Thread
Results 1 to 8 of 8

Wildcard macro to move file

  1. #1
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Exclamation Wildcard macro to move file

    Good Afternoon

    I am looking for a macro that can move a file I have that has a different name every day to another location.

    The file name for example is:

    test20130119

    the next day

    test20130120 etc

    I want to be able to use a wildcard search to search the location drive "z\" for a file that has the word test and then the rest that changes when it finds something it will then move the file elsewhere.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Wildcard macro to move file

    Does it have to search all of drive Z including sub-folders or do you know the specific folder to search e.g. "Z:\MyFolder\" ?

    This will move all "Test" files from one specific folder to another specific folder. It doesn't search subfolders. Change the Source and Destination paths to suit.

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,794

    Re: Wildcard macro to move file

    Hi AlphaFrog

    Perhaps adding some error trapping to your code if file exists in destination folder?

    Please Login or Register  to view this content.
    Alf

  4. #4
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Re: Wildcard macro to move file

    Thanks for you response

    The Z drive will have no sub folders it will only contain these files, Another thing I should have mentioned so my appologies could I reference a cell in my sheet to give this file a date once moved?

    for Example I added this to your code

    Please Login or Register  to view this content.
    but what it does is rename the file to test 1 which is fine but after that it also keeps the original file name so it looks like test 1 test123456

    I am doing this outside the office at the moment so will change the destinations tommorrow but thought I would try it out before hand.

    What I actually want is the macro to move it and rename the file as a given name and date, so if I was to put the date in cell A1 on Sheet 1 and the desired file name in cell A2 so it saves it as test 21-01-2013 would this be achieveable?
    Last edited by dave1983; 01-21-2013 at 03:38 PM.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Wildcard macro to move file

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 01-21-2013 at 03:57 PM.

  6. #6
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Re: Wildcard macro to move file

    Thanks again for your response

    I have been playing around trying to get this to work myself, A couple of things I have noticed with your code when I ran it is that:

    I have Test in cell A1 and then a date in cell A2 but it only seems to reference cell A1, when it moves the file it calls it Test Test and does not move it in an excel format

    what I want is the file to be called Test (or what ever is in cell A1 and then a date that is in A2.

    Thanks so much for your help it is much appreciated.

  7. #7
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Wildcard macro to move file

    Change this...
    Please Login or Register  to view this content.
    To this...
    Please Login or Register  to view this content.
    Change the file extension to suit.
    Last edited by AlphaFrog; 01-21-2013 at 04:37 PM.

  8. #8
    Forum Contributor
    Join Date
    04-17-2012
    Location
    england
    MS-Off Ver
    Excel 2010
    Posts
    122

    Re: Wildcard macro to move file

    Thats great thanks for all your help on this.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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