+ Reply to Thread
Results 1 to 2 of 2

Macro to Open a file that's name changes each week

  1. #1
    Registered User
    Join Date
    02-05-2015
    Location
    United States
    MS-Off Ver
    2007
    Posts
    13

    Macro to Open a file that's name changes each week

    I am trying to create a macro to open a file that's name changes each week. The file name is Labor - Week 7 - 1st.xls. Each week it will be a new number: 8, 9, 10, .... and so on. I have a macro that will open it for Week 7, but I don't know what to change.

    Sub DailyUpdate()
    '
    ' DailyUpdate Macro
    '

    '

    Workbooks.Open Filename:= _
    "\\spartanburg\SHARED\Production\Productivity\2015 Production Weekly\Labor - Week 7 - 1st.xls"
    Windows("Working attendance balance.xlsx").Activate

    End Sub






    I also need to make a second macro that will find and replace the worksheet from one week to the next. Like find and replace week 6 with week 7, based on the current week it is. Just like above it changes each week. This is what I have so far.

    Sub UpdateWeek()
    '
    ' UpdateWeek Macro
    '

    '
    Range("N11").Select
    Cells.Replace What:="Week 6", Replacement:="Week 7", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    Range("O4").Select
    ActiveCell.FormulaR1C1 = "6"
    Range("O6").Select
    Cells.Replace What:="Week 7", Replacement:="Week 6", LookAt:=xlPart, _
    SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
    ReplaceFormat:=False
    End Sub


    Please help. Thank you in advance.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,604

    Re: Macro to Open a file that's name changes each week

    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 here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ben Van Johnson

+ 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. Creating Code to open a file whose name changes by week
    By dafigu01 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-04-2014, 06:55 PM
  2. [SOLVED] Macro - Master file to import data from another open file with variable file name
    By jdodz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-10-2012, 10:56 PM
  3. Macro to save a file with a pre file name + week number from a cell
    By The.Dutchmaster in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-06-2012, 03:54 PM
  4. macro prompts immediately to open a file once the Excel file with the macro is opened
    By jhmayor03 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-03-2012, 10:00 AM
  5. [SOLVED] Open a file do a macro ( made) and open next succesive file
    By SVTman74 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-21-2006, 05:20 PM

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