Browse » Home
Wednesday, August 14, 2013
How to Program Excel Interfaces
1. Start Microsoft Excel, then open any worksheet or workbook.
2. Click on the 'Developer' tab. If you don't have this tab, click on the 'Microsoft Office' tab, then click on 'Excel Options.' Click on 'Popular' in the categories pane, and then select 'Show Developer tab in the Ribbon.' Click on 'OK' to close the dialog box. The 'Developer' tab will now be added to the toolbar.
3. Click on the 'Visual Basic' button. This will open the Visual Basic Editor (VBE).
4. Click on the 'Insert' tab and then click on 'New Module.' This opens a blank window where you can write your VBA code.
5. Write a short piece of VBA code to perform a task. For example, VBA code to bold characters is:Sub boldletter()' boldletter MacroSelection.Font.bold = TrueEnd SubThe macro should start with Sub (for subroutine) or Function, and end with End Sub or End Function. The first line of the code also contains the name of the subroutine followed by an open and closed parentheses, which is in this case is 'boldletter.' An apostrophe at the beginning of a line means that it is a comment.
6. Press the 'F5' key to run the macro.
7. Save the code by saving the workbook. Exit the VBE by pressing the 'alt' and 'F11' keys together. Click on the 'Microsoft Office' button and then click on 'Save.'