Page 432 - Computer Software Application TP - Volume 1
P. 432
COMPUTER SOFTWARE APPLICATION - CITS
Explanation :
This VBA macro is designed to calculate the area of a rectangle based on the length and breadth entered into
specific cells in an Excel worksheet. Let’s break down the code:
1 Variable Declarations:
• Two integer variables, length and breadth, are declared to store the dimensions of the rectangle.
2 Assigning Values:
• The length variable is assigned the value of the cell B2, which presumably holds the length of the rectangle.
• The breadth variable is assigned the value of the cell B3, which presumably holds the breadth of the
rectangle.
3 Calculating Area:
• The area of the rectangle is calculated by multiplying the length and breadth variables.
• The result is then displayed in cell B5 of the Excel worksheet.
4 Displaying Result:
• The message “Area is” is displayed in cell A5, followed by the calculated area in cell B5.
Explanation Summary:
• The macro retrieves the length and breadth of a rectangle from specific cells in the Excel worksheet.
• It calculates the area of the rectangle using the formula: Area=length×breadthArea=length×breadth.
• The calculated area is displayed in another cell of the worksheet, along with a descriptive label.
This macro simplifies the process of calculating the area of a rectangle in Excel, allowing users to quickly
obtain results based on the provided dimensions.
TASK 2: Create and modify a simple macro in Excel to calculate Body Mass Index (BMI) based on user
input of weight in kilograms and height in meters
Step 1: Open Ms Excel and press Alt+F11 to activate VBE(Visual Basic Editor) and go to Insert Module as
follows:
417
CITS : IT & ITES - Computer Software Application - Exercise 70 CITS : IT & ITES - Computer Software Application - Exercise 70