+ Reply to Thread
Results 1 to 2 of 2

VBA coding to look for files by date within file name in a given directory

  1. #1
    Registered User
    Join Date
    12-12-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    1

    VBA coding to look for files by date within file name in a given directory

    Hi there. I've written a bit of code that goes to a certain website, downloads monthly data files, and saves them in a directory that I have created, with names such as "domestic_report2014-Sep-BC". The monthly files' data is laid out horizontally, with Column A showing province, B showing time period (as MMM-YY, e.g. Sep-13), and columns C-L showing various sales data.

    What I'm trying to figure out now is how to write VBA coding that will go into the directory I created, and open the file that contains the date information in the file name that corresponds with the actual month/year (i.e. to pull the current month's data file). I am able to get the last date modified file open no problem with the below script. However, if I ever need to go look at older data files, this then makes an older file the latest date modified file, which is not good for my purposes, since I am ultimately appending each new file to a master excel sheet.

    By the way, this is my first post on Excel Forum! Any help at all is much appreciated

    HGD

    My current code:

    Please Login or Register  to view this content.
    Last edited by alansidman; 10-29-2014 at 05:02 PM. Reason: code tags added.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,872

    Re: VBA coding to look for files by date within file name in a given directory

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (Because you are new to the forum, I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ 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: 0
    Last Post: 03-13-2013, 09:08 PM
  2. Excel File Directory - List NEW Files only
    By lilanngel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-09-2013, 03:54 PM
  3. Return full file path for files in directory
    By jeffreybrown in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-03-2011, 12:42 PM
  4. List all files in directory in an Excel file
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-03-2009, 11:58 AM
  5. ***PLease help. Need to Merge directory of files into one file.***
    By Shani in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-04-2006, 11:55 AM

Tags for this Thread

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