Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8909527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:27:06+00:00 2026-06-15T03:27:06+00:00

My Excel VBA worksheet creates logs in a directory. Currently, the logs keep building

  • 0

My Excel VBA worksheet creates logs in a directory. Currently, the logs keep building up as I do not remove them.

However, now I would like to only keep the most recent 5. My logs are created with filenames as below:

<worksheet_name>_YYYYMMDD_HH_MM_SS.log

My current method of doing this job is to throw these logs into an array, sort the array, and keep only the first 5.

My question is this: Does anyone have a better method of keeping only the most 5 recent log files?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:27:07+00:00Added an answer on June 15, 2026 at 3:27 am

    That sounds like a workable solution. Use the FileSystemObject library to gather all the log files, then loop thru them.

    One option: you could try deleting based on Date Created or Date Modified, i.e. if the file was created over x days ago, delete it.

    Also, I don’t know how important these files are, but you may want to just move them to a folder called Archive instead of outright deleting them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel VBA Script I've written with help, I am not a
Am not that skilled at Excel/VBA and need some help. The code below (in
I would like to build an excel VBA program to find all the match
I'm trying to do something like this post but with Excel VBA. I would
When I program in Excel-VBA I use Hungarian notation. Worksheet variables start with ws,
I am trying to use the Worksheet Change Event in Excel VBA, but it
I am reading some cells of excel using VBA. Function getData(currentWorksheet as Worksheet, dataStartRow
I am currently able to enter csv file data into Excel VBA by uploading
I'm working on some VBA scripts for an Excel worksheet, and I've created a
In earlier versions of Excel, pressing CTRL+A in a worksheet would literally select all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.