Monday, November 16, 2009

Writing your own macros

When you recorded a macro, Excel created a module, added it to your workbook and wrote your recorded actions in a procedure belonging to that module.

When you want to write your own code in a new workbook you have to add a module to the workbook. The interface for macro development is called the Visual Basic Integrated Development Environment (IDE). Macro modules are displayed in the IDE instead of as a sheet in a workbook (as in versions before Excel 97).

How to Write Macro
Open a New Workbook.



  1. Click on the New button on the toolbar (or select New from the file menu and click OK)
  2. Then in the new workbook from the Tools menu, select Macro and then Visual Basic Editor.
  3. From the Insert menu in the Microsoft Visual Basic window. select Module.
  4. You can change the name of this module. In the Properties window, beside(Name). select the name Module1, and change it to Experimenting.
  5. Now Type sub myfirsttest and press Enter.. Note how the () and End sub are filled in automatically.
  6. Now type step by step instruction between the sub and end sub.
Sub is called procedure you also can use function for it but both are use for different purposes .
If you have a little bit of knowledge about Visual Basic it will help you on understanding and to help VBA code.

For Run your macro goto Run menu in Microsoft Visual Basic Window or press F5




No comments:

Subscribe Now: From your browser

Search:

Learn Office Excel