Applying Macro to all workbooks...

  • Thread starter Thread starter Trevor
  • Start date Start date
T

Trevor

Hello All,

I have created a macro that I need to use whenever I
import a text file. However, the macro is only associated
with the file that I wrote it in. How do I make it
available to any file I have open? As of now, I have to
go find the original file I wrote the macro for and
copy/paste the code into the current workbook. I know
there has to be a better way. Any help is much
appreciated.

Thanks.
 
hard to say without seeing the macro, but in general, if you use
activcecell, activesheet, activeworkbook rather than specific names for
these, it should work with the current workbook/sheet/cell.
 
Tom,

That's good info, thank you. But once I do that, how do I
access that macro when I open a new workbook?

Thanks for your help.
Trevor
 
Well, the macro has to be in an open workbook, so I would use a single
workbook to store my macros and open it when I need it or put it in the
xlstart directory and it will be opened whenever the workbook is opened.
There special provision made for such a workbook - the personal.xls
workbook. If you record a macro, excel offers to store the macro in
personal workbook. If you select this option and it doesn't exist, it is
created. If it already exists, the macro is stored there. this workbook is
opened whenever excel is opened (manually) and is marked as hidden so it
doesn't appear in excel. This is where most people place macros they want
to use as you describe.
 
Back
Top