+ Reply to Thread
Results 1 to 14 of 14

Automatically open and close external workbook for indirect function

  1. #1
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Automatically open and close external workbook for indirect function

    Hi everyone,

    I found the following bit of genius code from vane3261 he posted back in 2006 which is supposed to open an external workbook with a wildcard filename in order for an INDIRECT function formula to obtain results:

    Please Login or Register  to view this content.
    The INDIRECT code I'm using is as follows:

    Please Login or Register  to view this content.
    When I try to run the code I get error message: Object doesn't support this action and With Application.FileSearch is highlighted in yellow. Can anyone give me a hand in getting this corrected?

    Thanks!
    Last edited by Groovicles; 11-29-2013 at 11:28 AM.

  2. #2
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Automatically open and close external workbook for indirect function

    Hey guys. Any help? thanks!

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Automatically open and close external workbook for indirect function

    Hi, Groovicles,

    if you searched to find a code from 2006 you should have found all the threads as well stating that Application.FileSearch was abandonned with Office/Excel2007. Maybe use Dir() instead.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Automatically open and close external workbook for indirect function

    Hi,

    I tried to replace Application.FileSearch with Dir() and got an error. An other suggestions for a replacement or amending the code, guys?

    THanks,

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Automatically open and close external workbook for indirect function

    Hi, Groovicles,

    maybe like this:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  6. #6
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Automatically open and close external workbook for indirect function

    Hi Holger,

    Thanks. I'll be sure to try the code on Monday. Thanks for your help!

  7. #7
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Automatically open and close external workbook for indirect function

    Hi Holger,

    Thanks very much for the code. I tried it out this morning and unfortunatelly nothing happened. The external workbook did not open and I did not get any error message. Its funny. I put the code into the worksheet by right clicking on the worksheet tab and pressing View Code, but I don't see this code as a macro in my macro list. Am I missing something perhaps?
    Last edited by Groovicles; 12-02-2013 at 09:42 AM.

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Automatically open and close external workbook for indirect function

    Hi, Groovicles,

    unfortunatelly nothing happened
    Code goes behind the sheet where you change any entry. Go into the VBE and press F9 in then code line
    Please Login or Register  to view this content.
    and close the VBE. Any change in the worksheet should lead you into the VBE to have the possibility to step through the code by using F8 for finding out why the code won´t work. The first line of code will check and allow to work with the following code if Range C1 is changed and that´s the only cell to be changed on that event.

    The mark you set will be deleted once you close the file or by pressing F9 on that line again.

    Ciao,
    Holger

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: Automatically open and close external workbook for indirect function

    Instead if trying to use VBA to open a file for INDIRECT() to work, take a look at installing the MoreFunc, which will allow INDIRECT to to reference closed workbooks?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  10. #10
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Automatically open and close external workbook for indirect function

    Hi, FDibbins,

    would MoreFunc help when
    Please Login or Register  to view this content.
    is set? Sorry, have not installed that AddIn.

    Ciao,
    Holger

  11. #11
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Automatically open and close external workbook for indirect function

    In my situation I am not able to download any add-ins including Morefunc.

  12. #12
    Forum Contributor
    Join Date
    07-29-2013
    Location
    Oshawa
    MS-Off Ver
    Excel 2010
    Posts
    660

    Re: Automatically open and close external workbook for indirect function

    Hi Holger,
    Thanks for getting back to me. I tried your suggestion and still didn't get any error and the workbook still did not open. Arg this is killing me.

  13. #13
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: Automatically open and close external workbook for indirect function

    Holger, I have no idea, sorry

  14. #14
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Automatically open and close external workbook for indirect function

    Hi, Groovicles,

    please check the name of the file which is laid down in C1 and the path to it as if that workbook doesn´t exist (this returns a length of 0) no workbook will be opened. As yoiu didn´t pass any informatio about what is in cell C1 you are the only one to check that out.

    Ciao,
    Holger

+ 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. Indirect function with external sumif
    By Blen in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-25-2013, 07:15 AM
  2. Replies: 2
    Last Post: 09-11-2012, 09:42 AM
  3. Code to open a workbook, do what i want, close it, and open the next
    By stuartsjg in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-30-2010, 05:43 PM
  4. Save an open workbook, then open template workbook and close the saved workbook
    By ondvirg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2009, 10:20 PM
  5. INDIRECT update with external workbook
    By papa_face in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 05-03-2008, 06:24 AM

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