0

I have two workbooks workbook 1 and workbook 2. workbook 2 has workbook 1 as a reference through the VBA Editor > Tools > Reference property.

Whenever I open workbook 2, workbook 1 also opens automatically.

How do I suppress this as I do not want workbook 1 to always open as well?

AlmostThere
  • 557
  • 1
  • 11
  • 26
  • You can't. VBA needs to execute code from it, so it has to be in memory. I would suggest looking into [Slai's suggestion on your previous question](https://stackoverflow.com/questions/52916807/create-public-variable-that-can-be-used-in-multiple-excel-workbooks#comment92744206_52916807) or re-examining your architecture to see if you can simply eliminate the need for shared global variables. – Comintern Oct 21 '18 at 16:56
  • I really want it to work with the variables. Is there VBA syntax that can be used to add/remove references? – AlmostThere Oct 21 '18 at 18:21
  • I don't see how that solves the problem. If you add a reference dynamically, it still behaves the same way. – Comintern Oct 21 '18 at 18:24
  • Not necessarily, and maybe I need to create a new question or add on to my other question from your link above. My thought is I can duplicate the VBA in `workbook 2`, so one set of the VBA works as a stand alone and the second set of VBA works with `workbook 1`. For the second set of VBA in `workbook 2`, I could dynamically add the reference at the start of the VBA and then dynamically remove the reference at the end of the VBA, so the file does not get stored with the reference. So I wouldn't have to always have `workbook 1` opened. – AlmostThere Oct 21 '18 at 18:35

0 Answers0