+ Reply to Thread
Results 1 to 4 of 4

Use a variable between workbooks

  1. #1
    Forum Contributor
    Join Date
    09-18-2007
    Posts
    116

    Use a variable between workbooks

    I have some code that opens another workbook and runs a macro in the second workbook.

    Is there a way that I can use a variable that is set in the first workbook and read it in the code in the second workbook.

    Thanks

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Use a variable between workbooks

    Yes, any variables you set in your macro are available to use until the macro exits, even in secondary workbooks that are opened in the process. You'll have to present a more detailed question and some sample code showing what you want to do.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    09-18-2007
    Posts
    116

    Re: Use a variable between workbooks

    Code in workbook1

    Please Login or Register  to view this content.
    Code in second workbook

    Please Login or Register  to view this content.
    What I want to happen is Setup will only be called if the the workbook has not been opened by the first workbook.

    However data_feed_active in the second workbook is empty

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Use a variable between workbooks

    Before spending any time on your approach, I would simply disable other macros from running while my first macro is doing it's thing:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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