Chapter 9 – Using Macro in a Spreadsheet
I. Answer the following.
1. What is macro?
Macros are small programs that record your actions as you perform a task in
Calc.
2. How do you turn on the Macro Recorder?
To turn on the macro recorder, use Tools > Macro > Record Macro option. You
can observe a small Record Macro dialog box with a Stop Recording button.
3. Write the syntax to define a macro as a function.
The following is the syntax to define a simple function without parameters:
Function Function_Name()
Body of Function
Function_Name = Result
End Function
4. By default, which library is located in Calc?
By default, the Standard library is located in Calc.
II. Long answers.
1. How do you pass arguments to a macro?
A macro acts as a function. You can pass arguments (values/parameters) to a
macro when you call it.
To allow a macro to accept a value, simply type a name for that value between
the parentheses at the beginning of the macro. Syntax to define a macro with
parameters:
Function Function_Name(Optional Parameter1, Optional Parameter2,...)
Program code FunctionName = Result
End Function
Syntax to pass parameters to a macro while calling it:
=Function_Name(Parameter1, Parameter2,...)
2. Explain the use of macro with the help of an example.
Macros are small programs that record your actions as you perform a task in
Calc. When you run the macro later, it repeats your keystrokes and thus
actions. The Macros feature of Calc allows you to record a set of actions that
you perform repeatedly in a spreadsheet.
Let us consider an example, where a bookseller Rajneesh creates a report
every month to view the sales and calculate the profit. He colours the names of
the customers with overdue accounts in red and applies bold formatting to
them while creating the report. It means every time, he performs the repetitive
task to format the report, which takes a lot of his time and effort. To speed up
this work, he can create and run a macro to apply these formatting effects
quickly to the cells, whenever required