To import or export a VBA code module.
Sometimes we want to export all the subroutine code from one macro file (.xlsm) to another macro file (.xlsm). In such cases, instead of copying the individual subroutine we can export an entire module and import it in another excel macro file (xlsm).
Here we are showcasing how we can export and import the entire module in VBA Excel.
Export VBA Module
To export the module in a “.bas” file, we shall right click on the module and click on “Export File” option as shown in the image below.
Once we click on the “Export File” option, a dialog box will appear, which will ask us to save the module. A module is saved in the form of a “bas” file as shown below.
Import VBA Module
To import a VBA module, we shall right click on the module and click on “import file” option as shown below.
Once we click on “import file” option, a dialog box will appear, we shall select the “.bas” file and after this module will be inserted. In the image shown below we can see that we have imported the “module2” in the excel macro file.
Once we select the .bas file , module is inserted in macro file as shown below.We can import the VBA code by using this approach.
Post you may like