Using The Visual Basic Editor

When you export a copy of a module to a file, you can import it into any workbook. You can insert exported modules that Excel creates during the delete process into a project at any time by clicking File O Import File. You do not have to import the module back into the original project;you can insert it into any project. On the Import File dialog box, you highlight the appropriate module file to import and click Open. All VBA module files have the extension .bas. When you import a module file, the Visual Basic Editor tries to assign it the same name as the original module. If a module already exists with that name, the Visual Basic Editor adds 1 to the end of the module name. Therefore, if you named the original module Module1 and a Module1 exists in the project, Excel names the imported module Module11.

You do not need to delete a module to save it as a file. If you want to share your code with other Excel macro developers, you can simply export the module to a file that you can distribute. To export a macro you again select the module containing the macro and then click File O Import File.

I File Edit View Insert Format Debug Run lools Add-Ins Window Help

I File Edit View Insert Format Debug Run lools Add-Ins Window Help

Jîypëa question for help

Jîypëa question for help

. i ® Sheetl (Sheetl) : esheet2(5heet2) •B Sheet3(5heet3) : -e ThisWorkbook É-Q Modules

. i ® Sheetl (Sheetl) : esheet2(5heet2) •B Sheet3(5heet3) : -e ThisWorkbook É-Q Modules

Module? Module TJ Saveastype;

Alphabetic | Categorized |

Module? Module TJ Saveastype;

Alphabetic | Categorized |

-Q Select the folder in which you want to save the module code.

0 Type a name for the module code in the File name field.

Click Save.

1-lalxl

File Edit View Insert Format Debug Run lools Add-Ins Window Help a !>. - H I* > II • t£ I Si 6f 'S J? 0) Ln 12, c

Jîypëa question for help m g

é-Q Microsoft Excel Objet" If) Sheet 1 (Sheet 1)

Moduiel Module 3

Alphabetic | Categorized |

(Name) Moduiel

Calculate_E»penses

Sub SumCells[) add Hacco

Macro recorded 5/19/2001 toy Jinjei Keyboard Shortcut: Ctrl+d

-■ The Visual Basic Editor removes the module from the project.

Was this article helpful?

0 0

Post a comment