Advance Excel - Unit - I
Advance Excel - Unit - I
UNIT-I
Basics of Excel- Customizing common options- Absolute and relative cells- Protecting and
un-protecting worksheets and cells- Working with Functions - Writing conditional
expressions - logical functions - lookup and reference functions- VlookUP with Exact
Match, Approximate Match- Nested VlookUP with Exact Match- VlookUP with Tables,
Dynamic Ranges- Nested VlookUP with Exact Match- Using VLookUP to consolidate Data
from Multiple Sheets.
MS Excel in brief.
Microsoft Excel is a spreadsheet or a computer application that allows the storage of data in
the form of a table. Excel was developed by Microsoft and can be used on various operating
systems such as Windows, macOS, IOS and Android.
In Excel, there are two types of cell references: absolute and relative.
A relative cell reference is a reference to a cell that is relative to the position of the
formula. When you copy a formula that contains a relative cell reference, the reference will
change to refer to a different cell.
Example:
=A1
=A2
1
Absolute Cell Reference:
An absolute cell reference is a reference to a cell that remains the same even when
you copy the formula. Absolute references are denoted by a dollar sign ($) before the row
and column letters.
Example:
=$A$1
If you copy this formula to cell B2, it will still refer to cell A1.
Example:
=A$1
In this example, the column letter "A" is relative, but the row number "1" is absolute.
To protect a worksheet:
3. Select the protection options you want (e.g., password, formatting, editing).
5. Click OK.
This will prevent users from making changes to the worksheet, such as editing cells,
formatting, or inserting/deleting rows and columns.
To unprotect a worksheet:
2
3. Enter the password (if prompted).
4. Click OK.
This will remove the protection from the worksheet, allowing users to make changes again.
Note: You can also use the keyboard shortcut Alt + T + P to protect or unprotect a worksheet.
- Protecting a worksheet doesn't protect the data itself, just the formatting and structure.
- If you forget the password, you won't be able to unprotect the worksheet!
- You can also protect individual cells or ranges using the "Allow Users to Edit Ranges"
option.
Excel Formula
Microsoft Excel is the go-to tool for working with data. There are probably a handful
of people who haven’t used Excel, given its immense popularity. Excel is a widely used
software application in industries today, built to generate reports and business insights. Excel
supports several in-built applications that make it easier to use.
One such feature that allows Excel to stand out is - Excel sheet formulas. Here, we will
look into the top 25 Excel formulas that one must know while working on Excel. The topics
that we will be covering in this article are as follows:
Choose a cell.
To enter an equal sign, click the cell and type =.
Enter the address of a cell in the selected cell or select a cell from the list.
You need to enter an operator.
Enter the address of the next cell in the selected cell.
Press Enter.
3
There is another term that is very familiar to Excel formulas, and that is "function". The
two words, "formulas" and "functions" are sometimes interchangeable. They are closely
related, but yet different. A formula begins with an equal sign. Meanwhile, functions are
used to perform complex calculations that cannot be done manually. Functions in excel have
names that reflect their intended use.
The example below shows how we have used the multiplication formula manually with the
‘*’ operator.
This example below shows how we have used the function - ‘PRODUCT’ to perform
multiplication. As you can see, we didn’t use the mathematical operator here.
4
Excel Formulas and Functions
There are plenty of Excel formulas and functions depending on what kind of
operation you want to perform on the dataset. We will look into the formulas and functions
on mathematical operations, character-text functions, data and time, sumif-countif, and few
lookup functions.
1. SUM
The SUM() function, as the name suggests, gives the total of the selected range of cell values.
It performs the mathematical operation which is addition. Here’s an example of it below:
Sum "=SUM(C2:C4)"
As you can see above, to find the total amount of sales for every unit, we had to
simply type in the function “=SUM(C2:C4)”. This automatically adds up 300, 385, and 480.
The result is stored in C5.
2. AVERAGE
The AVERAGE() function focuses on calculating the average of the selected range of cell
values. As seen from the below example, to find the avg of the total sales, you have to simply
type in:
5
Fig: Average function in Excel
It automatically calculates the average, and you can store the result in your desired location.
3. COUNT
The function COUNT() counts the total number of cells in a range that contains a
number. It does not include the cell, which is blank, and the ones that hold data in any other
format apart from numeric.
COUNT =COUNT(C1:C4)
4. SUBTOTAL
Moving ahead, let’s now understand how the subtotal function works. The
SUBTOTAL() function returns the subtotal in a database. Depending on what you want, you
6
can select either average, count, sum, min, max, min, and others. Let’s have a look at two
such examples.
In the example above, we have performed the subtotal calculation on cells ranging
from A2 to A4. As you can see, the function used is
In the subtotal list “1” refers to average. Hence, the above function will give the average of
A2: A4 and the answer to it is 11, which is stored in C5. Similarly,
This selects the cell with the maximum value from A2 to A4, which is 12. Incorporating “4”
in the function provides the maximum result.
7
5. MODULUS
The MOD() function works on returning the remainder when a particular number is divided
by a divisor. Let’s now have a look at the examples below for better understanding.
In the first example, we have divided 10 by 3. The remainder is calculated using the
function
MODULUS =MOD(A2,3)
The result is stored in B2. We can also directly type “=MOD(10,3)” as it will give the
same answer.
Similarly, here, we have divided 12 by 4. The remainder is 0 is, which is stored in B3.
As you can see above, to find the power of 10 stored in A2 raised to 3, we have to type:
8
This is how power function works in Excel.
7. CEILING
Next, we have the ceiling function. The CEILING() function rounds a number up to its
nearest multiple of significance.
9. CONCATENATE
This function merges or joins several text strings into one text string. Given below are the
different ways to perform this function.
9
Fig: Concatenate function in Excel
10. LEN
The function LEN() returns the total number of characters in a string. So, it will count
the overall characters, including spaces and special characters. Given below is an example
of the Len function.
11. REPLACE
As the name suggests, the REPLACE() function works on replacing the part of a text
string with a different text string.
10
REPLACE =REPLACE(A15,1,1,"B")
“=REPLACE(A16,1,1, "A2")”
“=REPLACE(A17,1,2, "Sa")”
12. SUBSTITUTE
The SUBSTITUTE() function replaces the existing text with a new text in a text
string.
The syntax is “=SUBSTITUTE(text, old_text, new_text, [instance_num])”.
11
Here, [instance_num] refers to the index position of the present texts more than once.
Given below are a few examples of this function:
Next, we are substituting the second 2010 that occurs in the original text in cell A21 with
2016 by typing “=SUBSTITUTE(A21,2010, 2016,2)”.
Now, we are replacing both the 2010s in the original text with 2016 by typing
“=SUBSTITUTE(A22,2010,2016)”.
12
13. LEFT, RIGHT, MID
The LEFT() function gives the number of characters from the start of a text string.
Meanwhile, the MID() function returns the characters from the middle of a text string, given
a starting position and length. Finally, the right() function returns the number of characters
from the end of a text string.
In the example below, we use the function left to obtain the leftmost word on the sentence
in cell A5.
13
14. UPPER, LOWER, PROPER
The UPPER() function converts any text string to uppercase. In contrast, the
LOWER() function converts any text string to lowercase. The PROPER() function converts
any text string to proper case, i.e., the first letter in each word will be in uppercase, and all
the other will be in lowercase.
Let’s understand this better with the following examples:
Now, we have converted the text in A6 to a full lowercase one, as seen in A7.
Finally, we have converted the improper text in A6 to a clean and proper format in A7.
14
15. NOW()
The NOW() function in Excel gives the current system date and time.
16. TODAY()
17. TIME()
The TIME() function converts hours, minutes, seconds given as numbers to an Excel serial
number, formatted with a time format.
15
Fig: Time function in Excel
19. DATEDIF
The DATEDIF() function provides the difference between two dates in terms of years,
months, or days.
Below is an example of a DATEDIF function where we calculate the current age of a person
based on two given dates, the date of birth and today’s date.
16
Logical functions in Excel:
In Excel, logical functions are used to test conditions and make decisions based on data. Here
are some commonly used logical functions in Excel:
1. IF: Tests a condition and returns one value if true and another value if false.
4. AND: Tests multiple conditions and returns TRUE if all conditions are true.
5. OR: Tests multiple conditions and returns TRUE if any condition is true.
- Syntax: NOT(logical)
7. XOR: Tests two conditions and returns TRUE if only one condition is true.
Some examples:
These logical functions can be combined and nested to create more complex conditions and
decision-making logic in your Excel formulas.
17
Lookup and Reference Functions:
The VLOOKUP function in Excel is a powerful tool for searching and retrieving data from
a table or range. To perform an exact match using VLOOKUP, you can use the following
syntax:
VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
Where:
- lookup_value is the value you want to search for
- table_array is the range of cells that contains the data you want to search
- col_index_num is the column number that contains the value you want to return
- [range_lookup] is optional, but if set to FALSE, it will perform an exact match
Here's an example:
Suppose you have a table with the following data:
| Employee ID | Name | Department |
| --- | --- | --- |
| 101 | John Smith | Sales |
| 102 | Jane Doe | Marketing |
| 103 | Bob Johnson | IT |
If you want to find the department of an employee with ID 102 using an exact match, you
can use the following formula:
=VLOOKUP(102, A2:C4, 3, FALSE)
Where:
- 102 is the lookup value
- A2:C4 is the table array
- 3 is the column index number (Department)
- FALSE specifies an exact match
This formula will return "Marketing" as the result.
Note that if the lookup value is not found, the formula will return a #N/A error. You can use
the IFERROR function to handle this scenario:
=IFERROR(VLOOKUP(102, A2:C4, 3, FALSE), "Employee not found")
Approximate Match
An approximate match using VLOOKUP in Excel allows you to search for a value
that is close to, but not exactly equal to, the value in the lookup table. This is useful when
the data contains slight variations or errors.
To perform an approximate match using VLOOKUP, you can use the following
syntax:
VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
Where:
- lookup_value is the value you want to search for
18
- table_array is the range of cells that contains the data you want to search
- col_index_num is the column number that contains the value you want to return
- [range_lookup] is optional, but if set to TRUE or omitted, it will perform an approximate
match.
Here's an example:
Suppose you have a table with the following data:
| Employee ID | Name | Department |
| --- | --- | --- |
| 101 | John Smith | Sales |
| 102 | Jane Doe | Marketing |
| 103 | Bob Johnson | IT |
If you want to find the department of an employee with ID 102.1 (which is not an exact
match), you can use the following formula:
Where:
- 102.1 is the lookup value (which is not an exact match)
- A2:C4 is the table array
- 3 is the column index number (Department)
- TRUE specifies an approximate match
This formula will return "Marketing" as the result, as it finds the closest match (102) in the
Employee ID column.
Note that the approximate match works by finding the largest value in the lookup
column that is less than or equal to the lookup value. If there are multiple matches, it will
return the first one.
NESTED VLOOKUP
A nested VLOOKUP with an exact match! That's a powerful combination.
A nested VLOOKUP is when you use a VLOOKUP function as an argument within
another VLOOKUP function. This allows you to perform a lookup, and then use the
result of that lookup to perform another lookup.
To perform a nested VLOOKUP with an exact match, you can use the following
syntax:
=VLOOKUP(VLOOKUP(lookup_value1, table_array1, col_index_num1, FALSE),
table_array2, col_index_num2, FALSE)
Where:
- lookup_value1 is the value you want to search for in the first table
19
- table_array1 is the range of cells that contains the data for the first lookup
- col_index_num1 is the column number that contains the value you want to return
from the first lookup
- table_array2 is the range of cells that contains the data for the second lookup
- col_index_num2 is the column number that contains the value you want to return
from the second lookup
Here's an example:
Suppose you have two tables:
Table 1:
| Employee ID | Department ID |
| --- | --- |
| 101 | 10 |
| 102 | 20 |
| 103 | 30 |
Table 2:
| Department ID | Department Name |
| --- | --- |
| 10 | Sales |
| 20 | Marketing |
| 30 | IT |
If you want to find the department name of an employee with ID 102 using a
nested VLOOKUP with exact matches, you can use the following formula:
=VLOOKUP(VLOOKUP(102, A2:B4, 2, FALSE), E2:F4, 2, FALSE)
Where:
- 102 is the lookup value for the employee ID
- A2:B4 is the table array for the first lookup (Employee ID to Department ID)
- 2 is the column index number for the Department ID
- E2:F4 is the table array for the second lookup (Department ID to Department Name)
- 2 is the column index number for the Department Name
Using VLOOKUP with tables is a great way to perform lookups and retrieve data
from a table in Excel. In Excel, a table is a structured range of data that contains headers,
rows, and columns. When using VLOOKUP with tables, you can reference the table and its
columns by name, making the formula more readable and easier to maintain.
20
Here's the syntax:
Where:
- col_index_num is the column number that contains the value you want to return
For example, suppose you have a table named "Employees" with the following columns:
If you want to find the department of an employee with ID 102, you can use the following
formula:
Where:
21
Using VLOOKUP with tables makes it easy to perform lookups and retrieve data from a
structured range of data in Excel.
Combining dynamic ranges with nested VLOOKUPs and exact matches! That's a powerful
combination.
Here's an example of how you can use a dynamic range with a nested VLOOKUP and exact
match:
Table 1: Employees
Table 2: Departments
| --- | --- |
| 10 | Sales |
| 20 | Marketing |
| 30 | IT |
You want to find the department name of an employee with ID 102 using a nested
VLOOKUP with exact match, and you want the range to dynamically adjust to changes in
the data.
22
=VLOOKUP(VLOOKUP(102, Employees[Employee ID]:Employees[Department ID], 2,
FALSE), Departments[Department ID]:Departments[Department Name], 2, FALSE)
Where:
- 2 is the column index number for the Department ID and Department Name
This formula uses structured references to create dynamic ranges that adjust to
changes in the data. The first VLOOKUP finds the Department ID for the employee with ID
102, and the second VLOOKUP uses that result to find the Department Name.
Here's an example of how you can use VLOOKUP to consolidate data from multiple sheets:
Suppose you have multiple sheets with sales data for different regions, and you want
to consolidate the data into a single sheet to see the total sales for each product across all
regions.
Sheet 1 (North):
| Product | Sales |
| --- | --- |
| A | 100 |
| B | 200 |
| C | 300 |
Sheet 2 (South):
23
| Product | Sales |
| --- | --- |
| A | 150 |
| B | 250 |
| C | 350 |
Sheet 3 (East):
| Product | Sales |
| --- | --- |
| A | 200 |
| B | 300 |
| C | 400 |
You can use VLOOKUP to consolidate the data into a single sheet (Consolidated):
| --- | --- |
| A | 450 |
| B | 750 |
| C | 1050 |
Where:
24
- East!A:B is the range for the East sheet
This formula uses VLOOKUP to find the sales for each product in each sheet and
then adds them up to get the total sales.
You can also use a dynamic range to make the formula more flexible:
This formula uses the INDIRECT function to create a dynamic range that references the sheet
name and range.
****************
25