PDA

View Full Version : macro from one workbook updates another



316johniam
06-15-2006, 07:40 AM
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?

mdmackillop
06-15-2006, 08:11 AM
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.

316johniam
06-15-2006, 08:28 AM
Here's the code:

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

It errors out

316johniam
06-15-2006, 08:40 AM
The code is working off a private sub button click

lucas
06-15-2006, 08:41 AM
Is this the code thats supposed to open workbook B?

Cyberdude
06-15-2006, 12:49 PM
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.

316johniam
06-16-2006, 07:27 AM
Thanks guys. It now works.