Function - Name Argument - 1 Argument - 2
Function - Name Argument - 1 Argument - 2
Function - Name Argument - 1 Argument - 2
Introductory items:
1. A macro (or subroutine) is a group of statements (or code) that performs a set of tasks
without yielding a value back.
2. One could usually use the Record option. Often one may need to enhance the macros
directly by programming statements.
Guidelines for when to create a macro:
1. When the tasks are used often enough in which a template may be not be sufficient.
2. When the benefits (e.g. minimizing human errors in repeated tasks) outweigh the
programming effort.
Standard Format of Function
Sub function_name
( argument_1 ,argument_2,
statements and calculations
End Sub
Step 1. Open a new Excel spreadsheet and start macro recording by selecting
[View]
[Macro]
[Record Macro] and select [CTRL-a] as the hotkey.
Remarks:
1. VBA is object-oriented programming where each object can have properties or
procedures (methods) connected with each object. These are separated by periods
(.).
2. Variables can also be set to cell-ranges. Note the entry in Figure 5 of Range($A$1).
Remarks:
1. The first three lines selects the range of cells and assigns it to variable T.
Cells(2, 1).Select
Range(Selection, Selection.End(xlDown)).Select
Set T = Selection