The following macro opens the most recently modified file in a folder. How can I get it to open the most recently created file?
![]()
Please Login or Register to view this content.
The following macro opens the most recently modified file in a folder. How can I get it to open the most recently created file?
![]()
Please Login or Register to view this content.
Last edited by go3go3go; 01-16-2021 at 09:44 AM.
Administrative Note:
Welcome to the forum.
We would very much like to help you with your query, however you need to include code tags around your code.
Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.
Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
(Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
1. I care dog
2. I am a loop maniac
3. Forum rules link : Click here
3.33. Don't forget to mark the thread as solved, this is important
Sorry about that.
Ok. Please add this UDF :
And then change this line into :![]()
Please Login or Register to view this content.
As a note, there could be unexpected desired on how Windows treat the file creation and modification date.![]()
Please Login or Register to view this content.
Lets say a file "ABC.TXT" is created on 1 Jan 2021, and it has modified several times and the last modification date is 15 Jan 2021.
Now, as long as the file stay in the folder it is placed, then it will be working as expected -> the modification date will always bigger than creation date
But if this file "ABC.TXT" is copied to another folder, then for this copied file, the modification date will be the same but the creation date will be set as the current time the file being copied, so for this copied file, the creation date will be bigger than modification date.
The macro above just get the creation date reported by Operating System (you can check this by examining the file from Windows Explorer). Should this not what you expected, you need to change the code to fulfill your expectation.
Administrative Note:
Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!
For normal conversational replies, try using the QUICK REPLY box below or the REPLY button instead of REPLY WITH QUOTE.
Ali
Enthusiastic self-taught user of MS Excel who's always learning!
Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.
NB: as a Moderator, I never accept friendship requests.
Forum Rules (updated August 2023): please read them here.
You are welcome, thanks for marking the thread as solved.
Regards
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks