You will have to set the macro security to Medium or Low (not recommended) to enable the application to run macros.
The macro security can be set from this menu: Tools, Macro, Security.
- Select and copy the code you are interested in from the web page
(click and drag to select, press Ctrl+C to copy).
- Open a new workbook, or the workbook you want to use the code in.
- Press Alt+F11 to open the Visual Basic Editor (VBE).
- Select Insert, Module to insert a new code module into your workbook.
Some code examples are supposed to be pasted into special code modules (e.g. ThisWorkbook),
this will be specified on the web page with the example.
- Press Ctrl+V to paste the copied example code into the code module.
- Press Alt+F11 to go back to Excel.
- Press Alt+F8 to open the Macro dialog box.
- Double-click on the name of the macro you want to run.
If the name of the macro you want to run is not visible in the Macro dialog box, this can be caused by the fact that the macro need input to start, e.g.:
Sub ExampleMacro(strName As String)
MsgBox "Hello " & strName
The macro above can be started from another macro like this:
ExampleMacro "John Doe"
If you are using older versions of Excel you will probably get some error messages when opening a workbook or running a macro. This is caused by the fact that I’m usually using the latest edition of Excel when I create most of the examples, and I haven’t got the opportunity to test all examples in the older versions of Excel. Because of this the workbooks often refers to libraries that doesn’t exist if you have an older version of Excel. To remove the error messages you can do this:
- Select a module sheet in the workbook that causes the error message.
- Select the menu Tools, References.
- Remove the tick mark from the missing object libraries, add a reference to a similar (older) object library.
Click the OK-button.
- Save, close and reopen the workbook, this time the error message should be gone.
All macro programming is in US English. Some examples contains Norwegian text labels, but don’t be scared. You will probably see how to use them anyway.
Files marked with XL97 can only be used with Excel 97 or later.
Files marked with XL2000 can only be used with Excel 2000 or later.
Some files available for download are protected, you will probably not be able to view the code and edit the contents. Protected files are marked with Protected project.
Disclaimer: All files available for download are provided "as-is", without any warranty or support. All examples may be used free of charge, and you may adapt them for use in your own projects. All use of these examples and utilities is at your own risk. The files have been tested, but this does not guarantee that they will work on your machine.
NOTE: All files are compressed to make the file transfer go faster, you need 7zip, WinZip or similar to unpack the files.
If you have any requests or comments to these examples you may contact me by e-mail (see this page for contact information).
If you translate any of the Norwegian workbooks to another language I would appreciate a copy.