Ch 5 Using Macros in Spreadsheet Notes Important Points

Share with others

Chapter 5 Using Macros in Spreadsheet Notes Important Points

Using Macros in Spreadsheet Notes Important Points

Macros in Spreadsheet
Macro in Spreadsheet

Introduction

Many times, we require to perform repeated tasks such as typing school name, address, contact numbers with
a 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
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

  1. Click on Tools > Macros and then click on the Record Macro.
  2. Now start taking actions that will be recorded.
  3. Click on “Stop Recording” button to stop the recording of actions.
  4. Basic Macros dialog window open to save the Macro.
  5. Select the object in the Save Macro to list box.
  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 :

  1. Begin with a letter
  2. Not contain spaces
  3. Not contain special characters except for _ (underscore)

Running a Macro

To run a macro we need to perform the following steps.

  1. Click Tools > Macros > Run Macro
  2. Macro Selector dialog box will open.
  3. Select the library that contains the macro then select the macro under ‘Macro name’.
  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.

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

Important Macro Practical Activity

Create a simple Macro using BASIC programming instructions that will display Hello in a dialog box stored in the Standard module.

Macros in Spreadsheet
“Hello” in Dialog Box
  1. Open the LibreOffice Basic Macro dialog box using Tools > Macros > Organize Macros > Basic
  2. Click on Organizer.
  3. From Modules tab, select My Macros folder and click on New button.
  4. Give a name to the New Module say ‘Hello’ and click Ok.
  5. Select Hello and click Edit to open the Integrated Development Environment (IDE).
  6. Type Print “Hello” between Sub Main and End Sub.
  7. Run the macro by clicking on Tools>Macro>Run Macro

NOTE: The module can be executed from the IDE by either clicking the Run button or pressing F5.

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


Important links of Class X (IT – 402)

Unit 1: Digital Documentation (Advanced) using LibreOffice Writer

Chapter 1. Introduction to Styles – NOTES

Chapter 1. Introduction to Styles – Question Answers

Chapter 2. Working with Images – NOTES

Chapter 2. Working with Images – Question Answers

Chapter 3. Advanced features of Writer – NOTES

Chapter 3. Advanced features of Writer – Question Answers


UNIT 1: DIGITAL DOCUMENTATION (ADVANCED) – MCQ

UNIT-2: ELECTRONIC SPREADSHEET (ADVANCED) – MCQ

UNIT-3 RELATIONAL DATABASE MANAGEMENT SYSTEMS (BASIC) – MCQ


Disclaimer : I tried to give you the simple Notes of Chapter 5 Using Macros in Spreadsheet Notes Important Points , but if you feel that there is/are mistakes in the Notes of Chapter 5 Using Macros in Spreadsheet Notes Important Points given above, you can directly contact me at csiplearninghub@gmail.com. NCERT Book and Study material available on CBSE Website are used to create above article “Chapter 5 Using Macros in Spreadsheet Notes Important Points”



Share with others

Leave a Reply

error: Content is protected !!