+ Reply to Thread
Results 1 to 4 of 4

VB Code to delete files from folder

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB Code to delete files from folder

    Hello:

    I have lots of Subfolders named as STOREx in
    C:\Dropbox\EMail_Attachments\ and this is value in cell A3 of sheet1 in excel file.

    Example : C:\Dropbox\EMail_Attachments\STORENAME1
    C:\Dropbox\EMail_Attachments\STORENAME2

    All Subfolders have .xls file with the following format

    x-y-z_*.xls

    where
    x is the month between 1 and 12
    y is the day between 1 and 31
    z is the 2 digit year.

    Example : 9-1-15_Store1_Emp.xls
    10-15-15_Store2_TC_RPT.xls

    I need a VB Code to go thru each folder and delete the files based on Start date in cell A4 and End date in cell
    A5

    Please let me know if you have any questions.
    Thanks.

    RM

  2. #2
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: VB Code to delete files from folder

    Hi rizmomin
    Quote Originally Posted by rizmomin View Post
    ......
    I need a VB Code to go thru each folder and delete the files based on Start date in cell A4 and End date in cell A5...
    I recently did something very similar for someone, here:
    http://www.excelforum.com/excel-prog...-modified.html
    and here:
    http://www.excelforum.com/excel-prog...ubfolders.html

    The basic requirement seems similar to yours. The difference was that the criteria was the last time that any Files were updated, and the action was copying some data across depending on the criteria.
    But the basic requirement of going through sub Folders and taking action depending on cell values is the same i think to what you require.
    I suggest you see if these codes can get you started:
    http://www.excelforum.com/developmen...ml#post4213824
    http://www.excelforum.com/developmen...ml#post4213827
    The main difference is that the first code allows you to check cell values without opening the files, which i found neat..

    Have a go, then let us know how you get on and if you require further help. I will look in again ( if i can ) tomorrow.

    Alan
    '_- Google first, like this _ site:ExcelForum.com Gamut
    Use Code Tags: Highlight code; click on the # icon above,
    Post screenshots COPYABLE to a Spredsheet; NOT IMAGES PLEASE
    http://www.excelforum.com/the-water-...ml#post4109080
    https://app.box.com/s/gjpa8mk8ko4vkwcke3ig2w8z2wkfvrtv
    http://excelmatters.com/excel-forums/ ( Scrolll down to bottom )

  3. #3
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    Re: VB Code to delete files from folder

    Hi Alan:

    Seems like i will follow your link and complete ny task.
    Thanks a lot for your help.
    RM

  4. #4
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: VB Code to delete files from folder

    Hi rizmomin
    Quote Originally Posted by rizmomin View Post
    ....
    Seems like i will follow your link and complete ny task.
    Thanks a lot for your help....
    You are welcome. Thanks for the feedback
    Alan

+ 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] Excel VBA code for selecting a folder then search & open specified files in that folder
    By Excelrookie_1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2021, 03:09 AM
  2. [SOLVED] VBA Code to Move Individual Files from 1 Folder to a new Folder
    By mike.lawrie448 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 11-21-2014, 07:05 AM
  3. Delete old files in a specific folder
    By forfiett in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-26-2014, 02:37 AM
  4. [SOLVED] Delete excel files in a given folder
    By adrianrff in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2013, 03:18 PM
  5. Delete .csv files in a folder
    By John in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-02-2006, 02:10 PM
  6. Delete files within a folder
    By tarzan538 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-16-2006, 09:25 PM
  7. [SOLVED] Delete All Files in a folder
    By Michael Smith in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-08-2005, 01:05 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