Consulting

Results 1 to 7 of 7

Thread: macro from one workbook updates another

  1. #1
    VBAX Regular 316johniam's Avatar
    Joined
    May 2006
    Location
    Northern California
    Posts
    20
    Location

    macro from one workbook updates another

    workbook A= click vba button that calls a macro button from a different (closed) workbook

    There are four sheets in workbook B that use the same module (macro)

    how do I go about doing this?

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Save your macros in an XLA file as an Add-In, then you can call them from any book. You can add code to load/unload the add-in if only required for specific workbooks.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular 316johniam's Avatar
    Joined
    May 2006
    Location
    Northern California
    Posts
    20
    Location
    Here's the code:

    Workbooks("Unfunded Template.xls").Worksheets("My").Range("B12:E14").Select
    Selection.ClearContents

    It errors out

  4. #4
    VBAX Regular 316johniam's Avatar
    Joined
    May 2006
    Location
    Northern California
    Posts
    20
    Location
    The code is working off a private sub button click

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Is this the code thats supposed to open workbook B?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    If it's convenient, i.e., you are the only one running these macros, as an alternative to Malcom's suggestion about the Add-In, you can put the common macro in your Personal.xls workbook. I tend to prefer that technique, but if other folks will be using this, then the Add-In is probably preferable.

  7. #7
    VBAX Regular 316johniam's Avatar
    Joined
    May 2006
    Location
    Northern California
    Posts
    20
    Location
    Thanks guys. It now works.
    Do I look like I know what I'm doing?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •