Macros: can you copy macros from one doc to another?

  • Thread starter Thread starter Roady
  • Start date Start date
R

Roady

Hello: I have recorded 3 different macros in an Excel document. Problem is, I
already have 4 different other "working" copies of that document out there. I
wanted to enhance the other working copies with the macros so I copied and
pasted the macros into the other documents. Is this ok to do? It seems like
it is performing the macros but it keeps giving me an error message. In
addition, whenever I open a document and check the macros names, it always
lists the same ones. Does that mean that I have to re-name the macros or
recreate the macros in each working copy instead of copying? I am concerned
that it feeds back to the original document. Thank you!
 
It is ok to copy macros. You just can't reference the specific workbook name
usch as book1.xls because each file has a different name. Use Thisworkbook
to reference the workbook where the macro is located. Or get the name by
using thisworkbook.name.

You also must have the same sheetnames if you are referencing the sheets by
there actual names. If the code is failing you should get the failed line
highlighted and an error message. Posting the error and the highlighted line
will help solve the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top