0% found this document useful (0 votes)
8 views

Chapter 5 Macros Notes

Chapter 5 explains how to use macros in spreadsheets to automate repetitive tasks. It covers the process of recording, running, and organizing macros, as well as the rules for naming them. Additionally, it discusses how to create macros as functions for performing calculations across different sheets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Chapter 5 Macros Notes

Chapter 5 explains how to use macros in spreadsheets to automate repetitive tasks. It covers the process of recording, running, and organizing macros, as well as the rules for naming them. Additionally, it discusses how to create macros as functions for performing calculations across different sheets.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Chapter 5 - Using Macros in Spreadsheet

Macro in Spreadsheet
Introduction
Many times, we require to perform repeated tasks such as typing school name, address, contact numbers
witha specific formatting or apply the same formula at a particular cell for different sheets in a
workbook.
In this chapter, you will learn how to use a macro to automate repeated tasks that are always performed
in the same way over and over again.

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 Tools > Options > LibreOffice > Advanced. Observe the
Optional Features. There are two options which are not check marked. Put the checkmark on the option
“Enable macro recording”

Macros in Spreadsheet
Following actions are not recorded in Macro
1. Opening of windows
2. Actions carried out in another window than where the recording was started.
3. Window switching
4. Actions that are not related to the spreadsheet contents. For example, changes made in the Options
dialog, macro organizer, customizing.
5. The macro recorder works only in Calc and Writer.

Steps given below to record a macro


Step 1: Click on Tools > Macros and then click on the Record Macro.
Step 2 : Now start taking actions that will be recorded.
Step 3: Click on “Stop Recording” button to stop the recording of actions.
Step 4: Basic Macros dialog window open to save the Macro.
Step 5: Select the object in the Save Macro to list box.
Step 6: Type the name of the macro and click on Save button.

NOTE: By default the name of the macro is Main and is saved in the Standard Library in Module1. A
Library is a collection of modules which in turn is a collection of macros.

Rules for naming a Macro, Module or a Library:


While naming a Macro, Module or a Library the name should :
i) Begin with a letter
ii) Not contain spaces
iii) Not contain special characters except for _ (underscore)

Running a Macro
To run a macro we need to perform the following steps.
Step 1 : Click Tools > Macros > Run Macro
Step 2: Macro Selector dialog box will open.
Step 3 : Select the library that contains the macro then select the macro under ‘Macro name’.
Step 4: Click on Run to run the macro.

Code of a Macro
The action recorded by a macro is recorded as instructions in a programming language called BASIC. It
is also possible to view and thus edit the code of a macro. But remember, it is advised to edit a macro
only if you have knowledge of the language.

We can view the code generated for the macros by going to Tools > Macros > Edit Macros. Choose the
macro name from the Object Catalog and the associated code will be visible.

NOTE: The code of a macro begins with Sub followed by the name of the macro and ends with End
Sub. Do not make any changes to the code unless you are aware of the language.

Creating and Organising a Simple Macro


Steps to organize the macro.
Step 1: Click on Tools > Macros > Organize Macros > Basic
Step 2: Basic Macro Dialog window open.
Step 3: Click Organizer to open the Basic Macro Organizer dialog.
Step 4: Click on Library > New to create library to store macro.
Step 5: Click on Module tab and then New to create Module to store macro.

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

You might also like