+ Reply to Thread
Results 1 to 6 of 6

How to refer to the workbook where the macro when another workbook is open during runtime?

  1. #1
    Registered User
    Join Date
    05-23-2012
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    42

    How to refer to the workbook where the macro when another workbook is open during runtime?

    Basically I have 2 workbooks open at the same time say (WS and WB)
    WS<--- where the macro is
    WB<--- a workbook opened during runtime

    during runtime WB is activated to check for comparisons and if the values are not
    equal I need to write something on WS for the log and then continue the check on WB.
    how do I do this?

    I tried
    Please Login or Register  to view this content.
    but it results to error.
    Any help would be greatly appreciated thank you!
    Last edited by JBeaucaire; 09-04-2012 at 08:02 AM.

  2. #2
    Registered User
    Join Date
    05-23-2012
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: How to refer to the workbook where the macro when another workbook is open during runt

    it seems like its not on the workbook referencing that has an error...its
    the .value part...it says Run time error'1004'; Application-defined or object-defined error
    but I cant seem to figure out why because I'm pretty sure
    .value is a property of range.

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

    Re: How to refer to the workbook where the macro when another workbook is open during runt

    Your syntax above appears correct.

    THe error you've noted usually indicates an object may be missing and the only objects I see are ThisWorkbook and Sheets("log". Does that sheet exist in the workbook that stores that macro?
    _________________
    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!)

  4. #4
    Registered User
    Join Date
    05-23-2012
    Location
    Japan
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: How to refer to the workbook where the macro when another workbook is open during runt

    yeah....it does exists... I figured out how to solve this one...I used this
    Please Login or Register  to view this content.
    I don't know though how it solves the problem..bec. as far as I know
    range and cells are the same except for the parameters....

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

    Re: How to refer to the workbook where the macro when another workbook is open during runt

    You are correct. There is no objective difference between these two syntaxes:

    Please Login or Register  to view this content.

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

    Re: How to refer to the workbook where the macro when another workbook is open during runt

    If that takes care of your question, please select Thread Tools from the menu above and mark the thread as solved. Thanks.

+ 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