+ Reply to Thread
Results 1 to 6 of 6

VLookups Don't Update When Source Workbook is Opened via VBA

  1. #1
    Registered User
    Join Date
    01-08-2021
    Location
    Iowa, US
    MS-Off Ver
    2016
    Posts
    3

    Unhappy VLookups Don't Update When Source Workbook is Opened via VBA

    I have a main workbook that does calculation on data that is sourced from a separate workbook. I created a button on the main workbook that opens the source workbook for user convenience (that way they don't have to go digging through directories to find the source file).

    I assigned the following macro to the button to open the file:

    Please Login or Register  to view this content.
    My problem: the links in the main workbook still show a #REF! error even after pressing the button to open the workbook. If I open the source workbook manually, the links update fine, but using the VBA macro doesn't update the links, despite the workbook being opened.

    I've tried pressing the refresh all button, I've made sure the links and formulas are set to update automatically, I've even tried retyping the formulas in the cell and it still doesn't update.

    I believe the #REF! error is occurring in the INDIRECT function within my main workbook links, but it could be the VLOOKUP, I'm not totally sure. Just very lost at the moment.

    EDIT: A little more trouble shooting; problem definitely seems to lie in the INDIRECT function. I can retype a VLOOKUP into a different cell using a hard coded reference instead of the INDIRECT and the VLOOKUP works fine.

    Cheers,
    Matthew Mehrtens

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: VLookups Don't Update When Source Workbook is Opened via VBA

    No idea... but just a random thought. INDIRECT may not recalculate unless something changes in the destination sheet. Not a perfect solution, but as a starter can you add a character to a redundant cell on your destination sheet, and then delete it again - as part of your code - in an attempt to get INDIRECT to recalculate?
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: VLookups Don't Update When Source Workbook is Opened via VBA

    If the destination file is open and then you open the source file (without having done anything else) does the INDIRECT recalculate and work?

  4. #4
    Registered User
    Join Date
    01-08-2021
    Location
    Iowa, US
    MS-Off Ver
    2016
    Posts
    3

    Re: VLookups Don't Update When Source Workbook is Opened via VBA

    Yes! If I manually open the file with all my data in it, the calculator spreadsheet automatically updates all of the values. Additionally, if I manually open the data spreadsheet and then open my calculator spreadsheet, it updates fine as well.

    It's only when I use the VBA macro that's displayed in my original post that the spreadsheet won't update. It's like Excel doesn't realize that the data spreadsheet is open. But to throw an extra wrench into the puzzle, if I hardcode a file reference to the data spreadsheet into the VLOOKUP formula, it works fine. So, it has to be something with the INDIRECT formula, right?

    I tried your solution about modifying something on the data spreadsheet and then deleting it, but that didn't seem to change anything.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: VLookups Don't Update When Source Workbook is Opened via VBA

    I know ABSOLUTELY nothing about VBA... so I can't comment about it with anything other than TOTAL ignorance. But in my blissful state of stupidity, my guess it's your VBA. Can you add a line to the code to force a recalculation in your destination sheet? but that's pretty much what you already did....

  6. #6
    Registered User
    Join Date
    01-08-2021
    Location
    Iowa, US
    MS-Off Ver
    2016
    Posts
    3

    Re: VLookups Don't Update When Source Workbook is Opened via VBA

    I tried that as well... I tried adding the line:
    Please Login or Register  to view this content.
    to the end of the macro, but alas, nothing ):

+ 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. Replies: 8
    Last Post: 10-15-2015, 07:55 AM
  2. Replies: 0
    Last Post: 07-21-2015, 02:35 AM
  3. Chart not updated until chart sheet opened following source data update
    By untilyesterday in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-24-2013, 12:27 PM
  4. [SOLVED] update workbook without it being opened
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2013, 03:01 PM
  5. Update workbook without open XML source file
    By vietdieu in forum Excel General
    Replies: 0
    Last Post: 01-24-2012, 11:39 AM
  6. Replies: 2
    Last Post: 11-02-2011, 02:09 PM
  7. Update cells whose source is in a closed workbook
    By OilMan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-10-2010, 07:39 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