+ Reply to Thread
Results 1 to 6 of 6

Find a file to include today's date

  1. #1
    Registered User
    Join Date
    06-21-2013
    Location
    Cheltenham, England
    MS-Off Ver
    Excel 2013
    Posts
    45

    Find a file to include today's date

    Hi there,

    I'm currently posting this from my phone as my laptop has decided to die and I forgot my charger so ill try and explain as best I can without an example... I have a macro that opens a certain file and copies some data across before closing it.

    It all works fine however the files it will need to copy from change name every day in the form of "MI Data 25062013". At the moment there's a line in my Macro that shows the file path then a file name which I have stored on my PC that has the name of "MI Data" with no date.

    It would be much appreciated if anyone could point in the right direction as to how to auto read a file that contains today's date.

    Would be hugely appreciated.

    Thankyou in advance, you guys have been a massive help so far. Beginning to study VB now so hopefully in the near future I can start giving back on a large scale

  2. #2
    Forum Contributor
    Join Date
    05-29-2013
    Location
    MD
    MS-Off Ver
    Excel 365
    Posts
    148

    Re: Find a file to include today's date

    Hi,

    This page here might be a good start:
    http://stackoverflow.com/questions/1...lder-using-vba

    It explains how to loop through files in a particular folder.

    As for constructing the date, you can use the Format(Date, "DDMMYYYY") to return today's date as a string in the format you require.

    Cheers
    Duncan

  3. #3
    Registered User
    Join Date
    06-21-2013
    Location
    Cheltenham, England
    MS-Off Ver
    Excel 2013
    Posts
    45

    Re: Find a file to include today's date

    That looks very helpful however I've just been informed that the file name format is changing.

    It will now be 'Voyager (26JUN13)'. What would be the best way to find this?

    Thankyou.

  4. #4
    Registered User
    Join Date
    06-21-2013
    Location
    Cheltenham, England
    MS-Off Ver
    Excel 2013
    Posts
    45

    Re: Find a file to include today's date

    The current macro I have is as follows...

    Please Login or Register  to view this content.
    I get what you said about the file name but to get 'Voyager Test data 2' to change to 'Voyager (26JUN13)' is where I am struggling - I can't seem to get the 'Format Date' function you mentioned to work inside that.

    Anyone have any ideas? Thankyou in advance you lovely lovely people!

  5. #5
    Registered User
    Join Date
    06-21-2013
    Location
    Cheltenham, England
    MS-Off Ver
    Excel 2013
    Posts
    45

    Re: Find a file to include today's date

    I've got the above issue now working, however I'm wanting to expand it slightly.

    What I'm looking to do is, where the " & Format$(Date, "DDMMMYY" is in the one below, I'm looking for it to include the text that is in cell G16. Is there a way to do this? I've played around but haven't been succesful yet. Thankyou very much.

    Please Login or Register  to view this content.
    Any ideas?

  6. #6
    Registered User
    Join Date
    06-21-2013
    Location
    Cheltenham, England
    MS-Off Ver
    Excel 2013
    Posts
    45

    Re: Find a file to include today's date

    Never mind, I have got it working by simply naming the range and referencing it to there. Thankyou for your help on this matter

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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