Visual Basic for Applications
- Visual Basic for Applications is a programming language that is similar to Visual Basic, only it is embedded in an individual Microsoft application such as Excel or Access.
- Using VBA you can create macros or small programs that perform tasks within the Microsoft application.
- Macro is feature in MS Excel software which records all the steps and all the steps can be repeated whenever a same task is required to be performed. It helps in reduction of time in performing monotonous task.
- Macro is available in Tools menu
Record a Macro
1. On the Developer tab, click Record Macro.

2. Enter a name.
3. Select This Workbook from the drop-down list. As a result, the macro will only be available in the current workbook.

Note: if you store your macro in Personal Macro Workbook, the macro will be available to all your workbooks (Excel files). This is possible because Excel stores your macro in a hidden workbook that opens automatically when Excel starts. If you store your macro in New Workbook, the macro will only be available in an automatically new opened workbook.
4. Click OK.
5. Right mouse click on the active cell (selected cell). Be sure not to select any other cell! Next, click Format Cells.
Cells.

6. Select Percentage.

7. Click OK.
8. Finally, click Stop Recording.

Congratulations. You've just recorded a macro with the Macro Recorder!
Run a Recorded Macro
Now we'll test the macro to see if it can change the number format to Percentage.
1. Enter some numbers between 0 and 1.
2. Select the numbers.

3. On the Developer tab, click Macros.

4. Click Run.

Result:

See the Macro
To take a look at the macro, open the Visual Basic Editor.

Note: the macro has been placed into a module called Module1. Code placed into a module is available to the whole workbook. That means, you can select Sheet2 or Sheet3 and change the number format of cells on these sheets as well. Remember, code placed on a sheet (assigned to a command button) is only available for that particular sheet.