How to download & incorporate VBA code into Microsoft Excel
September 17, 2003

Download code:

Your browser may be configured to automatically download the BAS module by simply clicking on the link.  However, if opens up the file & shows the listing, then you must specifically instruct the browser to download the file, not open it.

From Internet Explorer:

  1. Right click on the link & choose "Save Target As...".
  2. Choose the location & name to save the file.  I'd recommend keeping the same name.  Pick a subdirectory in which you will have the spreadsheet that makes use of this code.
  3. Click the "Save" button.

From Mozilla
:
  1. Right click on the link & choose "Save Link Target As...".
  2. Choose the location & name to save the file.  I'd recommend keeping the same name.  Pick a subdirectory in which you will have the spreadsheet that makes use of this code.
  3. Click the "Save" button.

Incorporate code into Microsoft Excel spreadsheet:

The easiest way to incorporate the code is to import the module using the Visual Basic editor.

 
  1. Open up Microsoft Excel.  Create or open the spreadsheet to make use of the functions in the VBA module.
  2. Open the Visual Basic Editor by clicking on the menu items "Tools", "Macro", and "Visual Basic Editor".
  3. You should be able to see the Project window in the upper left hand side of the screen.  If not, click on the menu items "View" "Project Manager".
  4. Right click on the VBAProject with your file name.  Select "Import File...".  Go through the directory structure in the Import File box until you find the Visual Basic file that you want.  Select the file name & press "Open".
  5. You should now have a subfolder "Modules" for your file.  If you want to look at the code, press the "+" sign for the Modules to expand the list & double click on the module of interest.
  6. The VBA code is ready for use.  Go back to the Excel spreadsheet.  Select "Insert" "Function" (or the "fx" button) to bring up the Paste Function dialog box.  Select "User Defined" towards the bottom of the "Function category" list on the left.  You should now have a list of functions in the "Function Name" list on the right.  Select the function you'd like to use & click "OK".  You will now have a dialog box for the specific function.