Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a macro that I would like to use in some XLSX workbooks, call them wb1.xlsx and wb2.xlsx. Because they are XSLX they cannot contain any macro definitions.

My first choice to accomplish this was to use the Personal Macro Workbook in the XLSTART directory. However, I prefer that this not be global, that is, I do not want every workbook to access this macro, rather I would like only wb1.xlsx and wb2.xlsx to access the macro.

My next attempt was to define my macro in an Add-In, call it:


I checked the MyMacros item in the Manage Add-Ins list for wb1.xlsx, and then saw it was already there for wb2.xlsx. I then unchecked the MyMacros item in the Add-Ins list because I didn't want any future workbooks using it, but when I tried to open wb1.xlsx afterwards I received the error message:

Cannot run the macro "mymacro". The macro may not be available in this workbook or all macros may be disabled.

The reason for this is because MyMacros.xlam was no longer in the Add-Ins list. Apparently any change to the Add-In list is global rather than a property of a particular workbook.

Does anyone know of any other way to access a macro from some (not all) XLSX workbooks?

share|improve this question

You could save the macro in an .xlsm file and then save that macro enabled file plus your wb1.xlsx and wb2.xlsx as a workspace file (*.xlw). You can then open the workspace file, which will open all three workbooks in one swoop.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .