If you know Visual Basic programming then you can create your own VBA macro and run from within Excel.
Follow the steps below:
1. On the Tools menu select Macros.
2. On the Macro submenu select Visual Basic Editor.

3. You will be switched to Visual Basic Editor Menu.

4. On the Insert menu (Visual Basic Editor) select Module.
5. This will open the code window.

6. Type the Visual Basic code for your macro.
Here is a simple example. A macro to increment the variable i by 5 and write it to column 2 (Column B) in the next row :
Sub TestMacro()
Dim i As Integer, Row As Integer, Col As Integer
i = 0
Col = 2
For Row = 1 To 10
i = i + 5
ActiveSheet.Cells(Row, Col).Value = i
Next Row
End Sub
7. On the File menu click Close and return to Microsoft Excel.
8. Your new macro is now ready to be run.
To run your macro:
1. On the Tools menu select Macros. A list of available macros will be displayed.
2. Select your macro and click Run.
Applies to: Excel 2003

