+ Reply to Thread
Results 1 to 2 of 2

Help with Macro to Call Excel File with Variable Names

  1. #1
    Registered User
    Join Date
    07-24-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    20

    Help with Macro to Call Excel File with Variable Names

    Evening All,

    Need help with a Macro to open a specific file based on today's date or more to the point week number.

    I have a file which is named 'Daily Expectation Week ' (then the week number).

    I need to have a macro to call the file for this week, one for last week, & one for the following week.

    Can the macro see today's date, work out the week number like =weeknum() & use a -1 for previous week & +1 for the following week?

    All help appreciated as always.

    Cheers
    John

  2. #2
    Registered User
    Join Date
    07-24-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Help with Macro to Call Excel File with Variable Names

    Using WeekNum = DatePart("WW", Now()) before the standard call off of a file name, then adding " & WeekNum & " after the file name will give an addition to the file name being the week number.

    So if 'now' = 6th April, then 'WeekNum' = 14. This would create the following link 'Workbooks.Open Filename:="R:\Factory\PLANNING\2013\Site Utilisation & Production Figures 2013\Perod 4\Daily Expectation Week 14.xlsx'

    You can also add a variable to the 'WeekNum' by adding a '- 1' or '+ 1', this on the same date would return a 13 or a 15 at the end of the link.

    Please Login or Register  to view this content.
    Hope this helps!!

    John

+ 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