Comprehensive Notes Use Macros in Spreadsheet Information Technology Class 10 - TutorialAICSIP
Comprehensive Notes Use Macros in Spreadsheet Information Technology Class 10 - TutorialAICSIP
TutorialAICSIP
This site uses Google AdSense ad intent links. AdSense automatically generates these links and they may help creators earn money.
Comprehensive
notes Use macros in
spreadsheet
information
technology class 10
Topics Covered
1. Use macros in spreadsheet Information Technology
class 10
2. Record macro
2.1. Rules of naming macro
3. Running a macro
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 1/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
4. Creating and Organizing a simple macro
4.1. Creating a new library to store a macro
4.2. Creating a new module to store a macro
5. Macro As Function
5.1. Creating a macro as a function
6. Passing Argument to Macro Function
7. Using Macro function in Libre Office by Passing
Argument
8. Passing the arguments as values
9. Macros to work like built- in functions
10. Accessing cells directly
11. Sorting
Use macros in
spreadsheet Information
Technology class 10
While working with spreadsheet we need few tasks to be
repeated again and again. Macros allow to automate
repeated tasks in the same way over and over again.
Record macro
Macro records a series of commands or keystrokes in
spreadsheet. These can be recorded one time and then can
be used number times later.
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 2/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
1. Opening windows
2. Action carried out in another window than where
recording was started
3. Window switching
4. Action not related to the spreadsheet contents
5. Selection will be recorded only if the they are done by
using keyboard
6. The macro recorder works only in calc and writer
[1] Click on Tools > Macros > Record Macro option. Stop
recording button will open.
[3] It will open basic macros dialog box with Macro Name,
Save Macro in, Existing Macros in etc.
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 3/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
Running a macro
To run a macro in libre office calc, follow these steps:
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 4/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
[1] Click on Tool > Macros > Organize Macros > Basic
option.
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 5/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 6/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
[2] Type the new Name for library and click on OK.
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 7/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
Macro As Function
Sometimes we need to do some tasks repetitively in
spreadsheet. For example a same formula is used
frequently in spreadsheet on different cells and there is no
predefined function for it.
Social Science
Function <Function_Name>
tasks
End Function
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 8/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
Option Explicit
Sub Main
End Sub
Function pie_val()
pie_val=3.14
End Function
Using a function
Open spreadsheet and type the function with = sign as
below:
=pie_val()
Passing Argument to
Macro Function
A function may have some arguments. A macro function
can accept some arguments as values and as references.
Let us create a macro function that accept two values and
display the large number.
Function two_max(x,y)
If x>y Then
two_max=x
Else
two_max=y
End IF
End Function
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 9/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
Output 1:
Output 2:
Function SumCellsAllSheets()
Dim TheSum As Double
Dim i As integer
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 10/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
Dim oSheets
Dim oSheet
Dim oCell
TheSum = 0
oSheets = ThisComponent.getSheets()
For i = 0 To oSheets.getCount() - 1
oSheet = oSheets.getByIndex(i)
oCell = oSheet.getCellByPosition(0, 1) ' GetCell A2
TheSum = TheSum + oCell.getValue()
Next
SumCellsAllSheets = TheSum
End Function
Sorting
For sorting in through macros, following functions are
useful:
Sub SortRange
Dim oSheet ' Calc sheet containing data to sort.
Dim oCellRange ' Data range to sort.
REM An array of sort fields determines the columns that
are
REM sorted. This is an array with two elements, 0 and 1.
REM To sort on only one column, use:
REM Dim oSortFields(0) As New com.sun.star.util.SortField
Dim oSortFields(1) As New com.sun.star.util.SortField
REM The sort descriptor is an array of properties.
REM The primary property contains the sort fields.
Dim oSortDesc(0) As New com.sun.star.beans.PropertyValue
REM Get the sheet named "Sheet1"
oSheet = ThisComponent.Sheets.getByName("Sheet1")
REM Get the cell range to sort
oCellRange = oSheet.getCellRangeByName("A1:C5")
REM Select the range to sort.
REM The only purpose would be to emphasize the sorted
data.
'ThisComponent.getCurrentController.select(oCellRange)
REM The columns are numbered starting with 0, so
REM column A is 0, column B is 1, etc.
REM Sort column B (column 1) descending.
oSortFields(0).Field = 1
oSortFields(0).SortAscending = FALSE
REM If column B has two cells with the same value,
REM then use column A ascending to decide the order.
oSortFields(1).Field = 0
oSortFields(1).SortAscending = TRUE
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 11/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
REM Setup the sort descriptor.
oSortDesc(0).Name = "SortFields"
oSortDesc(0).Value = oSortFields()
REM Sort the range.
oCellRange.Sort(oSortDesc())
End Sub
By tutorialaicsip
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 12/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
Comprehensive note for class 10 share and
review a spreadsheet with libre office calc
Leave a Reply
You must be logged in to post a comment.
Trending
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 13/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 14/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 15/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
Latest
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 16/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 17/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 18/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 19/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 20/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
Name (required)
Email (required)
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 21/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
2 - Poor
3 - Average
4 - Good
5 - Excellent
Send Feedback
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 22/23
8/9/24, 1:44 PM Comprehensive Notes Use Macros In Spreadsheet Information Technology Class 10 | TutorialAICSIP
Powered by TutorialAICSIP
https://www.tutorialaicsip.com/it-402-x/comprehensive-notes-use-macros-in-spreadsheet-information-technology-class-10/ 23/23