+ Reply to Thread
Results 1 to 3 of 3

VBA - Referencing file with changing date

  1. #1
    Registered User
    Join Date
    12-02-2012
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    51

    Question VBA - Referencing file with changing date

    Hi all,

    I am trying to write a macro that copies data from a spreadsheet each month, however the name of the file will change each month to reflect the latest month. For example the spreadsheet will be titled 'Book1 Example 300613, then the next month the file will be titled Book1 Example 310713. Is there a way I can amend my code to pick up the latest month?

    Please Login or Register  to view this content.
    Thanks

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,441

    Re: VBA - Referencing file with changing date

    One way, maybe:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA - Referencing file with changing date

    The EOMONTH() formula will tell you the last day of any specific month.

    This will tell you the last day of this month:
    =EMONTH(TODAY(), 0)

    This will tell you the last day of last month:
    =EMONTH(TODAY(), -1)

    ...etc.

    With that you have all you need to "look" for the file based on end of month dates, say for the last 3 months.


    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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. Referencing in from files: Changing the reference file?
    By AMEY01 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-24-2013, 05:12 AM
  2. referencing file with date/time stamp
    By cabinetguy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-21-2011, 02:17 PM
  3. Replies: 3
    Last Post: 08-18-2010, 12:58 PM
  4. Referencing Changing File Names
    By Dave1674 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-15-2007, 12:19 PM
  5. Changing cell date in a file
    By Wilberforce in forum Excel General
    Replies: 7
    Last Post: 02-01-2007, 10:38 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