Gerhard Boenisch, created 02/28/2002, modified 05/21/2002; boenisch@bgc-jena.mpg.de
In the following instructions I unfortunately did not manage to be able to capture the pop-up menus, you have to read the text beside the figures.
![]() |
For starters a warning: Never open a file you do not know and have not specifically requested from someone else with "Macros Enabled". It could be your last action on this computer. ALWAYS DISABLE macros when opening unknown files! |
![]() |
In order to start writing programs in MS Excel, choose View - Toolbars - Visual Basic |
![]() |
Click the highlighted icon ![]() |
![]() |
Click the highlighted icon ![]() |
![]() |
Click the highlighted icon ![]() |
![]() |
Right-click the command button and choose View Code from the pop-up menu |
![]() |
This opens the Visual Basic Editor. Another way to open the Visual Basic Editor is to choose Tools - Macro - Visual Basic Editor from Excel. You can now rename the command button to something useful (changing "CommandButton1" highlighted in the lower left window in the figure on the left), and assign the command button a task by entering Call "procname" below the Private Sub CommandButton1_Click() line in the upper right window in the figure on the left. |
![]() |
Now choose Insert - Procedure from the menu of the Visual Basic Editor, type the name of the procedure into the name field (leave the other choices as shown) and press OK. Do not insert a second procedure called "restruct1" into this Excel program. Use a different name.
Type the code of your program into the new procedure or copy it from an example. |
![]() |
After finishing the code, select Debug - Compile VBAProject from the menu of the Visual Basic Editor. If no error message occures, congratulations, you have a working program. In case of error messages, correct them (HaHa!)!
Now press F8 to debug the program, watch as the variables appear in the lower right window in the figure on the left and how they change, when you run through your code line by line by repeatedly pressing F8. To stop the program, press the icon ![]() ![]() ![]() Now you can run the program by pressing the command button. |