macro notes
macro notes
2. Recording a Macro
✓ A macro is a single instruction that executes a set of instructions.
✓ These set of instructions can be a sequence of commands or
keystrokes that can be used for any number of times later.
✓ By default the macro recording feature is turned off when
LibreOffice is installed on our computer.
✓ Macro recording can be enabled by selecting,
6. Running a Macro
NOTE:
The module can be executed from the IDE by either clicking the Run
button or Pressing F5.
9. Macro as a Function
✓ Suppose we need to perform the same calculation again and again on
different sheets and there is no predefined function for it.
✓ In such a situation it will be convenient to create a macro that performs
the calculations.
✓ It will save our effort of remembering and typing the formulas.
✓ It is possible to do so if we use Macro as a function.
✓ Instead of writing instructions in between sub and End sub, we can write
instructions in between Function and End Function.
✓ A function is capable of accepting arguments or values.
10. Passing function without Parameters
SYNTAX:
Function <function Name> ()
<Function Name> () = <Value>
End Function
Ex:
Function Total ()
Total () = 10 + 20
End Function
11. Passing Function with Parameters
SYNTAX:
Function <Function Name> (optional <name>)
Function code
End Function
Ex:
1) Function double (optional A)
Double = A * 2
End Function
2) Function square (optional A)
Square = A * A
End Function
12. Steps to do Sort Macro
✓ Tools > Macros > Record Macro
✓ Select Range
✓ Data > Sort
✓ Select sorting category
✓ Stop Recording
✓ Save Macro
✓ Run Macro