+ Reply to Thread
Results 1 to 7 of 7

Referencing a closed workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    05-25-2015
    Location
    Toronto, Canada
    MS-Off Ver
    2007, 2013
    Posts
    4

    Re: Referencing a closed workbook

    Change the "weight" cell that's in summary workbook and the macro runs by itself for closed workbooks.. I guess, I'm trying to save a step of pressing the key for macro but now that I think about it...it's not really needed.

    So with that code, if I change the weight cell that's in summary workbook and run the macro, other closed workbooks should run in background and update it's values...and hence I should see the summary workbook pull new data. Am I correct?

    If so, I'll definitely give it a try tonight. Thanks!

  2. #2
    Forum Contributor
    Join Date
    07-25-2012
    Location
    Winterville, NC
    MS-Off Ver
    365 V2504 (16.0.18730)
    Posts
    144

    Re: Referencing a closed workbook

    Quote Originally Posted by blacktrek View Post
    Change the "weight" cell that's in summary workbook and the macro runs by itself for closed workbooks.
    Definitely...just instead of putting the code on the "This Workbook" object...go to the object that matches the tab name for the worksheet that you keep the "weight" cell on. This put this code there.

    Private Sub Worksheet_Change(ByVal Target As Range)
        Application.ScreenUpdating = False   'This turns off screen updating and speeds up macro
        Workbooks.Open Filename:="L:\Folder\Filename.xlsx"    'Opens the file (rinse)
        ActiveWorkbook.UpdateLink Name:= _
            "L:\Folder\Filename.xlsx", _
            Type:=xlExcelLinks    'Updates links (lather)
        Workbooks.Close Filename:="L:\Folder\Filename.xlsx"    'Close the file (repeat)
        '*********************
        'Copy paste the rinse/lather/repeat sections ;) here and change the file names for each file you have to open. (delete this line)
        '*********************   
        Application.ScreenUpdating = True    'This turns screen updating back on
    End Sub
    You could put the code in both places....the "This Workbook" one would make sure everything is updated when you first open the workbook and the one on the worksheet tab object would run if you make changes to the "weight" cell. But.....is that overkill? Are you just running the same update twice? Sorry...I can't tell without knowing how you use the workbooks!



    If you found this post to be helpful, or if it at least brought a smile to your face, please say "Thank You" by clicking Add Reputation. Thank you!

+ 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. Sumifs used referencing a closed workbook
    By kgallo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-20-2015, 06:57 PM
  2. [SOLVED] Trouble copying data from closed workbook into active workbook, referencing help
    By lepperga in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2013, 01:48 PM
  3. [SOLVED] Referencing a closed workbook
    By RowanB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-03-2012, 05:13 AM
  4. UDF referencing closed workbook not working
    By davegugg in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-25-2010, 09:17 PM
  5. referencing a named range from a closed workbook
    By Gixxer_J_97 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-08-2005, 04:06 PM

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