Lab02 Excel Manual
Lab02 Excel Manual
Learning Objectives
1. Able to use Excel Built-in Functions for Business Analytics.
2. Able to use Conditional Formatting to highlight important information.
Introduction
Microsoft Excel is a desktop application for data organization and comparison. For example, you may use it for
monitoring your personal monthly expenses and checking the balance whether it is out of budget by the end of
month. Your personal data are formatted in terms of rows and columns in an Excel’s worksheet.
In this laboratory, you will learn how to use some advanced built-in functions to analyze presented data.
1. AND Function
Syntax: AND(logical1, [logical2], …)
Example:
Function Result
=AND(TRUE, TRUE) TRUE
=AND(TRUE, FALSE) FALSE
=AND(A2=A4-A3, A3=2)
=AND(A5-A3=A3, A4=3, A2=A4)
2. OR Function
Syntax: OR(logical1, [logical2], …)
Example:
Function Result
=OR(TRUE, FALSE) TRUE
=OR(FALSE, FALSE) FALSE
=OR(A2=A4-A3, A3=2)
=OR(A5-A3=A1, A4=3, A2=A4)
1
ISOM2010 Introduction to Information Systems
Learning Outcomes
1. Distinguish the relations between Excel Macros and Excel VBA.
2. Learn to construct VBA programs by Macro recording.
3. Learn to construct or modify VBA programs using VB Editor.
4. Identify the three ways to run VBA programs (or known as Macros).
5. Understand how VBA works with business applications.
Introduction
In this laboratory, you will learn VBA (Visual Basics for Applications) as an advanced way to reduce your
time and workload on repeated tasks. More specifically, you will learn the various ways to construct and
run a VBA program.
1
ISOM2010 Introduction to Information Systems
Learning Outcomes
1. Handle interactions between user and VBA programs (also known as the construction of the user
interface) using input box for user data input and message box for information display to user.
2. Handle interactions between Excel worksheet cell values, input box and message box. And hence
make use of Excel worksheet cell values to run VBA programs.
Background Information
In this lab, we are going to construct a “user interface” in Excel VBA program.
Suppose we are going to input data to an Excel worksheet. Conventionally we select a cell, input the data
and go to the next cell. However, this means we have to make sure the correct cell has been selected
before we input the data. And for general users, sometimes they have no idea of where to input the data.
As a result, an input box from VBA program will be helpful.
Sub Input_Box_Demo()
End Sub
Running the VBA program will show the following box for user input.
Title
Prompt message
When the user clicks OK, contents input by the user will be stored in the variable price. But from the
user’s point of view, it seems nothing happened because the value stored will not be displayed. So we
also need an interface that can display values from VBA program to user.
Sub Message_Box_Demo()
MsgBox "The unit price has been saved.", vbInformation, "Price Saved"
End Sub
1
ISOM2010 Introduction to Information Systems
Learning Outcomes
1. Manipulate data using iterative (looping) statements.
2. Selection of data using conditional statements.
The marked price is expected to be the sum of cost and profit. Besides copy and paste the sum formula
throughout the column, we may make use of VBA iterative (looping) statements to compute the marked
prices of the products.
Do Until Condition_is_True
Statements_to_be_executed.
Loop
This is the VBA program that can compute the marked prices of the products:
Sub MarkedPrice()
Dim i As Integer
Dim count As Integer
Dim MarkedPrice As Double
i = 2
count = 0
Do Until IsEmpty(Cells(i, "A").Value)
MarkedPrice = Cells(i, "B").Value + Cells(i, "C").Value
Cells(i, "D").Value = MarkedPrice
i = i + 1
count = count + 1
Loop
MsgBox "Totally " & count & " items processed.", vbInformation, "Marked Price processed"
End Sub
1
ISOM2010 Introduction to Information Systems
Learning Outcomes
1. Learn about the basic concepts in database.
2. Understand the concept of entity (table), entity instance (record), attribute (field) and identifier
(key field).
3. Experience how to create and modify tables for data storage.
4. Experience how to create and modify queries for data retrieval.
Introduction
Microsoft Access is a desktop application for creating and maintaining databases. A database is a
collection of information that is related to a particular subject or purpose, e.g., a database that maintains
patients’ records for a clinic. The purpose of using a database is to coordinate and organize the
information in a way that a centralized repository is transparent to the end users even the physical data
are spread over different locations.
Imagine that you store your friends’ phone numbers in a paper-based phone book as well as in your
mobile phone’s contact list. If some of your friends change their phone numbers, you would have to
update the information in both places. To avoid the trouble of updating information more than once, it is
better to store data in a central location. All data and any changes made to the data are entered into this
location only. This arrangement not only makes the maintenance of the database much easier, but also
guarantees the integrity of the data (i.e. same data will not have two different versions). To retrieve the
data, users must get access to the database. In practice, a computerized database management system
allows users to retrieve the information that they want and presents it in a nice format.
In this laboratory, you will learn some basic functions of Microsoft Access and a few key concepts in
database management systems.
This view is called Datasheet view in Access. Note that Access’ table looks very similar to Excel
worksheet and data are stored in rows (also known as records) and columns (also known as
fields). This table contains the information about the customers.
1
ISOM2010 Introduction to Information Systems
Learning Outcomes
1. Experience how to create and modify tables for data storage using SQL.
2. Experience how to create and modify queries for data retrieval using SQL.
Introduction
SQL (Structured Query Language) is a domain-specific language used in programming and designed for
managing data held in a relational database management system (RDBMS). It is particularly useful in
handling structured data where there are relations between different entities/variable of the data.
In this laboratory, you will learn some key SQL commands: INSERT, UPDATE, DELETE and SELECT.
1. INSERT Command
Syntax:
INSERT INTO table (field1, field2, …) VALUES (value1, value2, …)
3. We would like to add a new product record in the ProductInfo table using SQL.
4. Click Create Query Design, a new Query1 will appear.
5. Close the Show Table window.
6. Click View SQL View
7. Details of the new product:
1
ISOM2010 Introduction to Information Systems
How can we use INSERT command to add new member to MemberInfo table?
Answer:
INSERT INTO MemberInfo VALUES (100041, "Chan", "Olivia", 6, 23587653, "New Territories")
Answer:
Answer:
Task 4: Retrieve Purchase Record (Member Name, Purchase Date, Product ID, Quantity) of those who
bought product in February
You may fill in the blanks below:
1
ISOM2010 Introduction to Information Systems
Learning Outcomes
1. Experience how to create and modify Forms.
2. Experience how to create and modify Reports.
Introduction
A form in Access is a database object that you can use to create a user interface for a database
application. A "bound" form is one that is directly connected to a data source such as a table or query,
and can be used to enter, edit, or display data from that data source. Alternatively, you can create an
"unbound" form that does not link directly to a data source, but which still contains command buttons,
labels, or other controls that you need to operate your application.
Reports offer a way to view, format, and summarize the information in your Microsoft Access database.
For example, you can create a simple report of phone numbers for all your contacts, or a summary
report on the total sales across different regions and time periods.
1. FORMS
There are three types of forms that you can create in Access: Form, Multiple Items, Split Form
1
ISOM2010 Introduction to Information Systems
Split Form: Display Form view and Datasheet view at the same time
You can use the datasheet portion of the form to quickly locate a record, and then use the form portion
to view or edit the record.
3. We would like to create a user-friendly form for MemberInfo table, so that user can view, edit
and delete the record easily.
4. Click Create Form, MemberInfo form will appear.
5. In order to create a user-friendly form, we would need to change the text into an easy
understandable wording in the form within the Layout View.
MEM_ID MEM_Last_Name MEM_First_Name
Member ID Last Name First Name
MEM_Gender MEM_Month MEM_Contact_No
Gender Birthday Month Contact Number
MEM_Regions MEM_DM
Living Region Agree to receive Direct Marketing?
2
ISOM2010 Introduction to Information Systems
6. Now, we may redesign the Layout of the form by changing the Textbox to Option Group for the
MEM_Gender field.
6.1 Under Design View: Click Design Option Group, drag it next to the MEM_Gender Textbox
6.2 Option Group Wizard popped out, type the value as below:
6.5 Click “Store the value in this field: MEM_Gender” and Next >
6.6 Click Option buttons and Next >
6.7 Leave the caption as defalut and click Finsih
6.8 Delete the MEm_Gender textbox, Caption and put the Option Group in the right place
3
ISOM2010 Introduction to Information Systems
7. We may also change the Textbox to Combo Box for the MEM_Regions field.
7.1 Under Layout View: Click Design Combox Box, place it next to the Living Region label.
7.2 Combo Box Wizard popped out, click “I will type in the values that I want.” and Next >
7.3 Type the values as below:
7.4 Click “Store that value in this field: MEM_Regions” and Next >
7.5 Leave the Combox Box label as default and click Finish
7.6 Delete the MEM_Regions textbox, Combox Box label and put the Combo Box as below
8. Layout of the MemberInfo Form:
4
ISOM2010 Introduction to Information Systems
1. Under Layout View: Click on the Data Tab in the Property Sheet
2. Set the Default Value OR Validation Rule with meaningful Validation Text for the below field:
5
ISOM2010 Introduction to Information Systems
6
ISOM2010 Introduction to Information Systems
2. REPORTS
Example: Create a Report to show Monthly Purchase Record for PurchaseRecord table
1. Click Database Tools Relationships
7
ISOM2010 Introduction to Information Systems
9. Click Add a group Group on PRO_Name with PUR_Quantity [Type: SUM; Show subtotal in
group header]
Summary
This is not a Design Course. No need to remember all the steps on how to create the Forms and Reports.
You just need to remember the basic concept of Forms and Reports and what we can do with them:
8
ISOM2010 Introduction to Information Systems
Task 5: Retrieve which customer has bought product in their Birthday Month
You may fill in the blanks below:
Expected Result:
Answer:
2
ISOM2010 Introduction to Information Systems
9. Click Run button and you will see the below warning:
10. Click Yes and Refresh All, you will see the new record shown in the ProductInfo table.
How can we use INSERT command to add new member to MemberInfo table?
2. UPDATE Command
Syntax:
UPDATE table SET newvalue WHERE criteria
4. Click Run button and you will see the below warning:
2
ISOM2010 Introduction to Information Systems
5. Click Yes and you will see the updated record shown in the MemberInfo table.
3. Delete Command
Syntax:
DELETE field FROM table WHERE criteria
* = all fields
3. Copy the below coding under the SQL view
DELETE * FROM MemberInfo WHERE MEM_ID = 100041
4. Click Run button and you will see the below warning:
5. Click Yes and you will see the member record is deleted in the MemberInfo table.
4. SELECT Command
Syntax:
SELECT field FROM table WHERE criteria
Example: Find out which members have a contact number starting with 9
1. Click View SQL View
2. Copy the below coding under the SQL view
SELECT * FROM MemberInfo WHERE MEM_Contact_No Like "9*"
OR
SELECT MEM_Last_Name, MEM_First_Name, MEM_Contact_No FROM MemberInfo WHERE
MEM_Contact_No Like "9*"
3
ISOM2010 Introduction to Information Systems
3. Click Run button and you will see the below result:
Example: Retrieve Purchase Information (Member Names, Product Name, Price and Quantity) of those
who had purchase product that is priced over 200 and purchase amount greater than 1
1. Click View SQL View
2. Copy the below coding under the SQL view
SELECT MEM_Last_Name, MEM_First_Name, PRO_Name, PRO_Price, PUR_Quantity
FROM MemberInfo, ProductInfo, PurchaseRecord
WHERE PRO_ID = PUR_PRO_ID AND PUR_MEM_ID = MEM_ID
AND PRO_Price > 200 AND PUR_Quantity > 1
3. Click Run button and you will see the expected result.
3. You may revise the SQL so that it has a meaningful field name for COUNT.
SELECT COUNT(*) AS MarchMember FROM MemberInfo WHERE MEM_MONTH = 3
Example: Find out the distribution of Birthday Month for all Member
1. Click View SQL View
2. Copy the below coding under the SQL view
SELECT MEM_Month, COUNT(*) AS NoOfMember FROM MemberInfo GROUP BY MEM_Month
What will happen if you run the below SQL? ERROR WARNING MESSAGE
SELECT MEM_Month, COUNT(*) AS NoOfMember FROM MemberInfo
4
ISOM2010 Introduction to Information Systems
Example: Find out the most expensive product for each Member has bought
1. Click View SQL View
2. Copy the below coding under the SQL view
SELECT MEM_ID, MAX(PRO_Price) AS MaxPrice
FROM MemberInfo, ProductInfo, PurchaseRecord
WHERE PRO_ID = PUR_PRO_ID AND PUR_MEM_ID = MEM_ID GROUP BY MEM_ID
Task 4: Retrieve Purchase Record (Member Name, Purchase Date, Product ID, Quantity) of those who
bought product in February
You may fill in the blanks below:
Task 5: Retrieve which customer has bought product in their Birthday Month
You may fill in the blanks below:
Expected Result:
5
ISOM2010 Introduction to Information Systems
Short Text Use for text or combinations of text and numbers. 255 characters maximum
Long Text Memo is used for larger amounts of text. Stores up to 64,000 characters.
Currency Use for currency. Holds up to 15 digits of whole dollars, plus 4 decimal places.
OLE Object Pictures, graphs, or other ActiveX objects from another Windows-based
application.
Lookup Wizard Let you type a list of options, which can then be chosen from a drop-down list.
2
ISOM2010 Introduction to Information Systems
2. Give each field a Name (PRO_ID, PRO_Name, PRO_Price, PRO_Size, PRO_Weight) and specify
their Data Type (as listed in the following table).
3. Designate the Primary Key Field: Right-click, and select Primary Key on the short-cut menu.
4. Click Save and name this table as Product Information.
3
ISOM2010 Introduction to Information Systems
4. To insert or delete a record, right-click on the record and then select New / Delete Record from
the short-cut menu.
1. On the window toolbar, click the Create Tab. Choose Query Design.
4
ISOM2010 Introduction to Information Systems
6. To run your query, press the button ( ). (Note: Make sure you have closed all the other tables
when perform the query.)
7. To modify your query, click the button ( ) to go back to the Design View of the query.
8. Save your query as “qryLike9”.
1. On the database window toolbar, click Create, and then choose Query Design.
2. Add Customer Information, Product Information and Purchase Record.
5
ISOM2010 Introduction to Information Systems
3. Link the CUST_ID field of Customer Information to the PUR_CUST_ID field of Purchase Record by
dragging CUST_ID to PUR_CUST_ID.
Link the PRO_ID field of Product Information to the PUR_Item_ID field of Purchase Record by
dragging PRO_ID to PUR_Item_ID.
4. Create a query that shows the following information ― i.e. CUST_Last_Name, CUST_First_Name,
PRO_Name, PRO_Price and PUR_Quantity ―which the item is priced over 200.
6
ISOM2010 Introduction to Information Systems
Furthermore, we may incorporate input box to allow user inputs. For example:
Sub SellingPrice()
Dim i As Integer
Dim count As Integer
Dim Discount As Integer
Dim DisRate As Double
Dim SellPrice As Double
i = 2
count = 0
Do Until IsEmpty(Cells(i, "A").Value)
SellPrice = Cells(i, "D").Value * DisRate
Cells(i, "E").Value = SellPrice
i = i + 1
count = count + 1
Loop
MsgBox "Totally " & count & " selling prices done.", vbInformation, "Selling Price done"
End Sub
Task A:
In the Excel worksheet "TaskAnB", design an interface to process the data in the table.
1. User should use input box to input the discount (in % off) of the products. The input will be
confirmed by a message box and then display in cell F1 of the table.
2. Calculate the Selling prices of the products. And store the value in appropriate cells.
3. Display a message box reporting the number of items processed at the end.
2
ISOM2010 Introduction to Information Systems
Conditional statements
When we want to process the data differently according to some conditions, we can use conditional
statements If ... Then and If ... Then ... Else.
If Condition_is_True Then
Statements_to_be_executed.
End If
If Condition_is_True Then
Statements_to_be_executed_when_True.
Else
Statements_to_be_executed_when_False.
End If
CouponAmt = 50
Membership = InputBox("What is your membership?", "Input membership")
If Membership = "VIP" Then
CouponAmt = CouponAmt * 4
End If
MsgBox "You will get $" & CouponAmt & " coupon.", vbInformation, "Your coupon"
End Sub
Sub About_Today()
Dim Weather As String
Dim Feeling As String
Sub Your_Age()
Dim Age As Integer
Dim About_You As String
Sub Classification()
Dim i As Integer
Dim Category As String
Dim CatCount As Integer
Dim NonCatCount As Integer
i = 2
CatCount = 0
NonCatCount = 0
Category = InputBox("Enter the counting Category", "Find your Category")
Do Until IsEmpty(Cells(i, "B").Value)
If Category = Cells(i, "A").Value Then
CatCount = CatCount + 1
Else
NonCatCount = NonCatCount + 1
End If
i = i + 1
Loop
MsgBox "There are " & CatCount & " items for " & Category & ". And " & NonCatCount & " items
for others.", vbInformation, "Final report"
End Sub
Task B:
In the Excel worksheet "TaskAnB", finish the followings making use of both iterative and conditional
statements.
1. User input the Category first by input box. Copy the input category to an appropriate cell. And then
the subroutine will go through the entries (records) in the product list table one by one.
(Hint: Using Do-Until Loop.)
2. If a record that matches the input category is found, copy the data (Product Name, Unit Price and
Pricing based on) to appropriate cells next to the list. Also increment the item counter by 1.
3. If a record does not match the input category, increment another item counter by 1.
4. Finally, display a message box (or two separate message boxes) reporting the number of items
belong to and not belong to the input category respectively.
4
ISOM2010 Introduction to Information Systems
Running the VBA program will show the following message box.
Title
Display the user’s input message in the message box (make use of concatenation):
The following VBA program output shows how to include user’s input in the message box display.
This can be done by concatenating text strings of “fixed contents” with user’s input variable using “&”
operator.
Sub Display_user_input()
MsgBox "The unit price $" & price & " has been saved.", vbInformation, "Price Saved"
End Sub
When the user input “3” and click OK in the input box. The user input will be displayed as part of the
message in the message box.
Declare variables
In the previous example, it seems VBA automatically recognize the variable “price”. However, we
should always declare a variable with meaningful name and proper data type before using.
Sub Display_user_input_Modified()
Dim price As Double
price = InputBox("Enter the
MsgBox "The unit price $" & price & " has been saved.", vbInformation, "Price Saved"
End Sub
Besides storing user inputs, variables are also very useful to store calculation results. For example:
Sub FX_USD_to_HKD()
Dim USD_Amt As Double
Dim HKD_Amt As Double
USD_Amt = InputBox("Enter the amount of USD", "USD to HKD")
HKD_Amt = USD_Amt * 7.8
MsgBox "USD$" & USD_Amt & " = HKD$" & HKD_Amt, vbInformation, "Currency Exchange"
End Sub
Task 1:
Making use of input boxes, design an interface for user to input the followings:
Then calculate the revenue generated by the relation “revenue = Unit Price * Quantity Sold”. Making use
of message box, display a mess age including all the user inputs. The VBA program output looks like t his:
3
ISOM2010 Introduction to Information Systems
Interactions between input / output values and Excel worksheet cells in VBA
In Excel VBA we can access a certain Excel worksheet cell with the “Cells” keyword.
The following VBA program shows how to assign a user input value to a certain cell.
Sub Store_user_input_Cell()
Dim price As Double
On the other hand, the following VBA program shows how to display a certain cell’s value using message
box.
Sub Display_Cell_Value()
Dim price As Double
Dim output As Double
Task 2:
Make a copy of VBA program named Task_01() and renamed it as Task_02(). With reference to
the contents in worksheet named Task02. Modify VBA program Task_02() as follows:
1. After the user input the product name, unit price and quantity sold, contents will be stored in
appropriate cells of the table.
2. The calculated revenue will also be stored in appropriate cell.
3. The number of items input will be updated in cell B1.
(Hint: Besides what you need in task 1, you will also need to make use of the value in cell B1.)
4
ISOM2010 Introduction to Information Systems
Task 2: Construct a VBA program by Macro Recording; Run a VBA program by Run Macros
By using Excel Macro Recording, user interactions will be recorded as VBA program code. And the VBA
program (or known as Macro) can be replayed later. So it is very useful if the interactions have to be
repeated many times. Now you are going to record a Macro that can plot a stock chart.
There are two worksheets, namely 3988.HK and 0005.HK, we will record the steps on 3988.HK
worksheet and later we will replay the steps for 0005.HK.
11. Choose My_First_Macro and click Run button to replay the Macro.
2
ISOM2010 Introduction to Information Systems
Task 3: Construct a VBA program by VB Editor; Run a VBA program by clicking a button
In this part, you are going to develop a VBA program that calculates the daily stock closing price change.
1. On the same stock data worksheet, select DEVELOPER > Visual Basic in the Ribbon.
A new window pops up, and this window is called Visual Basic Editor (VBE). In VBE, you can
create your own programming code for a button, list box, menu, etc.
i = 2
Do Until IsEmpty(Cells(i + 1, "G"))
Cells(i, "H").Value = Cells(i, "G").Value - Cells(i + 1, "G").Value
i = i + 1
Loop
End Sub
4. Go back to the stock data worksheet window.
5. Insert a Button to call the VBA program in Step 3.
i) Select DEVELOPER in Ribbon.
ii) Select Insert > Button.
iii) Use the mouse to drag a rectangular shape in order to create a button.
iv) Choose Calculate_Change and click OK button.
6. Click the button to run the VBA program. You will have the similar result below.
3
ISOM2010 Introduction to Information Systems
Sample outlook:
Instruction
1. Select the Slot Machine worksheet.
2. Copy the VBA program code (listed in the next page) to a Visual Basics Editor Module window.
3. Insert a button and assign the PlaySlotMachine VBA program to the button.
4
ISOM2010 Introduction to Information Systems
VBA Code
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
' Between each draw, stop (sleep) for some time to let people see the flashing
' effects.
' If num1=1 then return happy face in cell B2, elseif num1=2
' then return normal face in cell B2. '
' All other value will return unhappy face in cell B2
If num1 = 1 Then
Cells(2, "B").Value = "J"
ElseIf num1 = 2 Then
Cells(2, "B").Value = "K"
Else
Cells(2, "B").Value = "L"
End If
num2 = Int(Rnd() * 3 + 1)
If num2 = 1 Then
Cells(2, "C").Value = "J"
ElseIf num2 = 2 Then
Cells(2, "C").Value = "K"
Else
Cells(2, "C").Value = "L"
End If
num3 = Int(Rnd() * 3 + 1)
If num3 = 1 Then
Cells(2, "D").Value = "J"
ElseIf num3 = 2 Then
Cells(2, "D").Value = "K"
Else
Cells(2, "D").Value = "L"
End If
'The closer to the end of the draw, the slower are the flashing effects
Sleep count * 4
Next count
If you are using Mac version of Excel, please make the below two statements as comment:
'Sleep count * 4
These two lines are used to perform slow animation in Windows version Excel.
5
ISOM2010 Introduction to Information Systems
1. The display message will be different for 3 happy faces, 3 normal faces and 3 sad faces.
2. The program will display another message when all three pictures are different.
Q2. Do we have to modify the VBA program if we use 3 other different pictures?
Summary
6
ISOM2010 Introduction to Information Systems
3. IF Function
Syntax: IF(logical_test, [value_if_true], [value_if_false])
Example:
Function Result
=IF(B2<>"", "No Error", "Missing Category") No Error
=IF(C2>0, "No Error", "Invalid Price") No Error
Q1. How to change the IF Function so that it gives out the same result as “=IF(C2>0, "No Error", "Invalid Price")”?
Hint: =IF(_________, "Invalid Price", __________)
Ans:
Q2. How to combine the below two IF Functions into one Function?
Function Result
=IF(B5<>"", "No Error", "Missing Category") Missing Category
=IF(C5>0, "No Error", "Invalid Price") Invalid Price
Hint: Using 1 AND Function and 2 IF Function
Expected Result:
Ans:
Function Result
=COUNTIF(B2:B7, "Stationery") 4
=COUNTIF(B2:B7, B4)
=COUNTIF(C2:C7, ">=150")
2
ISOM2010 Introduction to Information Systems
Function Result
=VLOOKUP(600, A2:D4, 2, TRUE) Silver
=VLOOKUP(600, A2:D4, 2, FALSE) #N/A
=VLOOKUP("Gold", B2:D4, 2, FALSE)
Q1. How to write the VLOOKUP Function to find out the corresponding Member Type of Kitty?
Ans:
Q2. If the member is new member, he/she can enjoy the New Member Discount. How to write the VLOOKUP
Function to find out the Discount Rate of Tony? (Hint: Using IF Function)
Ans:
3
ISOM2010 Introduction to Information Systems
Ans:
4
ISOM2010 Introduction to Information Systems
Q2. How to write the IF Function so that it gives out the below expected result?
Hint: Using Array Formula, Press Ctrl+Shift+Enter to enter the formula
Expected Result:
Ans: