+ Reply to Thread
Results 1 to 4 of 4

Loop Through All Files In Folder And Delete As Per Condition

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Loop Through All Files In Folder And Delete As Per Condition

    Hi guys,

    I have a folder containing about 500 different files, and I have a list of about 100 client that i need to copy the reports from those 500 different files to a folder.
    Going through individually will take forever, and I have to do this every year.

    1 thing is that all the files are named as per follow:
    XXXXX_XX_CONTRACT#_BLABLA

    In my excel list, I have a list of all the contract #(5 digits) to be pulled in column A.

    So I am thinking if I can have a VBA file that can go through each file in a folder and if the contract# match the filename, then copy the file to another location.

    Anyone can help out on this?

    Thanks.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Loop Through All Files In Golder And Delete As Per Condition

    The path and a sample would clarify your need - so:

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    440

    Re: Loop Through All Files In Golder And Delete As Per Condition

    This is an example of the task to be done. Please note that the Second Path folder should be empty, then after clicking the Copy button in the VBA File, it will copy the 2 files from the Main Path folder to the Second Path folder.

    See below attachment:
    VBA.zip

    Thanks.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Loop Through All Files In Golder And Delete As Per Condition

    Try this:

    Please Login or Register  to view this content.
    *Start with VBA File active

+ 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: 12
    Last Post: 03-09-2015, 05:52 PM
  2. [SOLVED] Loop through files in folder
    By danielgri14 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-26-2014, 01:57 PM
  3. VBA Loop for a folder of all the files, Loop all the worksheet in each workbook
    By nanjingwoodworking in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-07-2013, 07:20 PM
  4. loop through all files in a folder except for one of them
    By masben in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2013, 10:23 AM
  5. Loop through files in a folder
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-28-2010, 06:03 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