+ Reply to Thread
Results 1 to 7 of 7

Delete old files in a specific folder

  1. #1
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Italy
    MS-Off Ver
    Excel 2010
    Posts
    162

    Delete old files in a specific folder

    Good evening,

    While searching on google for a code that will delte all files that are old more than xx days in a specific folder, I found out bellow code:

    Please Login or Register  to view this content.
    but unforunatelly is not working for me.
    It pups up a error saying: Dir_Path = "C:\Folder\SubFolder\" --> VARIABLE NOT DEFINED.

    Do you have any Idea how to handle it?

    Best regards,
    forfiett
    I get a error

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Delete old files in a specific folder

    The macro is looking for the folder called "Subfolder" in the Folder "Folder" in your C Drive.

    Does it exist?

  3. #3
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Italy
    MS-Off Ver
    Excel 2010
    Posts
    162

    Re: Delete old files in a specific folder

    Good day,

    Yes it exist.

    Best regards,
    forfiett

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Delete old files in a specific folder

    Hi, forfiett,

    what about using
    Please Login or Register  to view this content.
    without the last backslash?

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Italy
    MS-Off Ver
    Excel 2010
    Posts
    162

    Re: Delete old files in a specific folder

    Dear Holger,

    Have tried also this option without result.
    Maybe do you have any other similar code?

    Best regards,
    forfiett

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Delete old files in a specific folder

    Hi, forfiett,

    if you have fuill access to the folder and the files are of file extension xls maybe try it like this:
    Please Login or Register  to view this content.
    Please mind that all files of the extension xl* should be deleted in the givern directory if the are older than seven days.

    Ciao,
    Holger

  7. #7
    Forum Contributor
    Join Date
    12-13-2012
    Location
    Italy
    MS-Off Ver
    Excel 2010
    Posts
    162

    Re: Delete old files in a specific folder

    Good day,

    I will try it. Thanks.

    Best regards,
    forfiett

+ 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: 1
    Last Post: 01-28-2019, 06:55 PM
  2. Extract specific column data from specific sheet from multiple files in a folder
    By piggyfox in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-31-2013, 11:51 AM
  3. Replies: 1
    Last Post: 01-24-2006, 11:35 AM
  4. Replies: 1
    Last Post: 01-24-2006, 11:00 AM
  5. Replies: 1
    Last Post: 01-24-2006, 12:25 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