Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Automating Copying Macros.
Written by Allen Wyatt (last updated August 19, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365
Sreekanth asked if there is a way to automate the copying of macros from one workbook to another. It seems that Sreekanth has to create a new "distribution" workbook each month that contains a PivotTable that analyzes data, and the workbook needs to contain certain macros.
Perhaps the easiest way to do this is to create a new Excel template that contains only the macros you want to distribute. Then, you can use that template as a basis for your distribution workbook. Simply copy your PivotTable to the workbook, and it will be ready to distribute, as needed.
You could also, if desired, created an Excel add-in that contains the macros you want. (How you create add-ins is discussed in other ExcelTips.) You could then send the add-in to all recipeints of your distribution workbook and ask them to install the add-ins on their system.
If you would rather not use a template or mess with an add-in, then you can create a macro that will copy macro procedures from one workbook to another. Such a macro can get rather involved, and would take some testing. A good place to start in developing such a macro is a great online resource located at this Web page:
http://www.cpearson.com/excel/vbe.aspx
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11655) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Automating Copying Macros.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Do you often need to know the difference between two values in your worksheet? This tip shares a quick little macro that ...
Discover MoreWant to know how much of a time difference there is between your machine and a different machine? This tip provides some ...
Discover MoreVBA makes it easy to copy a worksheet from the current workbook into a brand-new workbook. You may want to delete some ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2023-08-19 11:03:25
J. Woolley
For related discussion, see https://excelribbon.tips.net/T011855_Automating_the_Importing_of_Macros.html
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments