0% found this document useful (0 votes)
13 views

Excel - Part IV

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Excel - Part IV

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

IV - Advance & Complex Functions

VLOOKUP Function
Use VLOOKUP, one of the lookup and reference functions, when you need to find things in a table or a
range by row. For example, look up an employee's last name by her employee number, or find her phone
number by looking up her last name (just like a telephone book).
The secret to VLOOKUP is to organize your data so that the value you look up (employee’s last name) is
to the left of the return value you want to find (employee’s phone number).
Syntax
VLOOKUP (lookup_value, table_array, col_index_num, [range_lookup])
For example:

• =VLOOKUP(105,A2:C7,2,TRUE)
• =VLOOKUP("Fontana",B2:E7,2,FALSE)

Argument name Description


The value you want to look up. The value you want to look up must be in the first
column of the range of cells you specify in table-array .
lookup_value (required) For example, if table-array spans cells B2:D7, then your lookup_value must be in
column B. Lookup_value can be a value or a reference to a cell.
The range of cells in which the VLOOKUP will search for the lookup_value and
the return value.
table_array (required) The first column in the cell range must contain the lookup_value. The cell range
also needs to include the return value (for example, First Name in the graphic
below) you want to find.
The column number (starting with 1 for the left-most column of table-array) that
col_index_num (required) contains the return value.

A logical value that specifies whether you want VLOOKUP to find an exact
match or an approximate match:
• TRUE assumes the first column in the table is sorted either numerically
range_lookup (optional) or alphabetically, and will then search for the closest value. This is the
default method if you don't specify one.
• FALSE searches for the exact value in the first column.

INDEX function
The Microsoft Excel INDEX function returns either the value or the reference to a value from a
table or range.
Syntax
INDEX(array, row_num, [column_num])
The INDEX function syntax has the following arguments.

• Array Required. A range of cells or an array constant.


o If array contains only one row or column, the corresponding Row_num or
Column_num argument is optional.

Page 1 of 9
o If array has more than one row and more than one column, and only Row_num or
Column_num is used, INDEX returns an array of the entire row or column in array.
• Row_num Required. Selects the row in array from which to return a value.
If Row_num is omitted, Column_num is required.
• Column_num Optional. Selects the column in array from which to return a value.
If Column_num is omitted, Row_num is required.

Example:

No Name Age Village


1 Lili 45 Paris
2 joe 35 beirut
3 tony 24 lyon
4 leo 25 marseille
5 laura 32 milan
6 lea 8 lausanne

Search by INDEX
Row 3
column 1

Result =INDEX(B2:D7,3,1)
Search by VlookUp
Name Joe
Village =VLOOKUP(B3,B3:D7,3,0)

Advanced Functions: SUMIF, COUNTIF, AVERAGEIF

1. SUMIF( )

Syntax
SUMIF(range, criteria, [sum_range])
The SUMIF function syntax has the following arguments:

• range Required. The range of cells that you want evaluated by criteria. Cells in each range must
be numbers or names, arrays, or references that contain numbers. Blank and text values are
ignored.
• criteria Required. The criteria in the form of a number, expression, a cell reference, text, or a
function that defines which cells will be added. For example, criteria can be expressed as 32,
">32", B5, "32", "apples", or TODAY().

Page 2 of 9
Important Any text criteria or any criteria that includes logical or mathematical symbols must be
enclosed in double quotation marks ("). If the criteria is numeric, double quotation marks are not
required.

• Sum_range Optional. The actual cells to add, if you want to add cells other than those specified
in the range argument. If the sum_range argument is omitted, Excel adds the cells that are
specified in the range argument (the same cells to which the criteria is applied).

• You can use the wildcard characters—the question mark (?) and asterisk (*)—as the criteria
argument. A question mark matches any single character; an asterisk matches any sequence of
characters. If you want to find an actual question mark or asterisk, type a tilde (~) preceding the
character.

Example

Category Food Sales

Vegetables Tomatoes $2,300.00

Vegetables Celery $5,500.00


Fruits Oranges $800.00
Butter $400.00
Vegetables Carrots $4,200.00
Fruits Apples $1,200.00

Description Result Function


Sum of the sales of all foods in the "Fruits"
=SUMIF(A2:A7,"Fruits",C2:C7)
category. $ 2,000.00
Sum of the sales of all foods in the "Vegetables"
=SUMIF(A2:A7,"Vegetables",C2:C7)
category. $ 12,000.00
Sum of the sales of all foods that end in "es"
=SUMIF(B2:B7,"*es",C2:C7)
(Tomatoes, Oranges, and Apples). $ 4,300.00
Sum of the sales of all foods that do not have a
=SUMIF(A2:A7,"",C2:C7)
category specified. $ 400.00

2. COUNTIF( )
The COUNTIF function counts the number of cells that meet criteria you specify.
Syntax
COUNTIF(range, criteria)
For example:

• =COUNTIF(A2:A5,"apples")
• =COUNTIF(A2:A5,A4)

Page 3 of 9
Argument name Description
The group of cells you want to count. Range can contain numbers, arrays, or
range (required)
references that contain numbers. Blank and text values are ignored.
A number, expression, cell reference, or text string that determines which cells will
be counted.
For example, you can use a number like 32, a comparison like ">32", a cell like B4,
criteria (required)
or a word like "apples".
COUNTIF uses only a single criteria. Use COUNTIFS if you want to use multiple
criteria.
Examples

Data Data
apples 32
oranges 54
peaches 75
apples 86

Description Result Function


Counts the number of cells with apples in cells
=COUNTIF(A2:A5,"apples")
A2 through A5. 2
Counts the number of cells with peaches (using
=COUNTIF(A2:A5,A4)
criterion in A4) in cells A2 through A5. 1
Counts the number with oranges (using
criterion in A3) and apples (using criterion in =COUNTIF(A2:A5,A3)+COUNTIF(A2:A5,A2)
A2) in cells A2 through A5. 3
Counts the number of cells with a value greater
=COUNTIF(B2:B5,">55")
than 55 in cells B2 through B5. 2
Counts the number of cells with a value not
equal to 75 in cells B2 through B5. The
ampersand (&) merges the comparison =COUNTIF(B2:B5,"<>"&B4)
operator for not equal to (<>) and the value in
B4 to read =COUNTIF(B2:B5,"<>75"). 3
Counts the number of cells with a value greater
=COUNTIF(B2:B5,">=32")-
than (>) or equal to (=) 32 and less than (<) or
COUNTIF(B2:B5,">85")
equal to (=) 85 in cells B2 through B5. 3
Counts the number of cells containing any text
in cells A2 through A5. The asterisk (*) is used
=COUNTIF(A2:A5,"*")
as the wildcard character to match any
character. 4
Counts the number of cells that have exactly 7
characters that end with the letters "es" in cells
A2 through A5. The question mark (?) is used =COUNTIF(A2:A5,"?????es")
as the wildcard character to match individual
characters. 2

Page 4 of 9
3. AVERAGEIF( )
The Microsoft Excel AVERAGEIF function returns the average of all numbers in a range of cells,
based on a given criteria.
Syntax
AVERAGEIF(range, criteria, [average_range])
The AVERAGEIF function syntax has the following arguments:
• Range Required. One or more cells to average, including numbers or names, arrays, or
references that contain numbers.
• Criteria Required. The criteria in the form of a number, expression, cell reference, or text that
defines which cells are averaged. For example, criteria can be expressed as 32, "32", ">32",
"apples", or B4.
• Average_range Optional. The actual set of cells to average. If omitted, range is used.
Remarks

• Cells in range that contain TRUE or FALSE are ignored.


• If a cell in average_range is an empty cell, AVERAGEIF ignores it.
• If range is a blank or text value, AVERAGEIF returns the #DIV0! error value.
• If a cell in criteria is empty, AVERAGEIF treats it as a 0 value.
• If no cells in the range meet the criteria, AVERAGEIF returns the #DIV/0! error value.
• You can use the wildcard characters, question mark (?) and asterisk (*), in criteria. A question
mark matches any single character; an asterisk matches any sequence of characters.

Examples
Property
Commission
Value
100000 7000
200000 14000
300000 21000
400000 28000

Description Result Function


Average of all commissions less than
23000. Three of the four commissions meet 14000 =AVERAGEIF(B2:B5,"<23000")
this condition, and their total is 42000.
Average of all property values less than
250000. Two of the four property values
150000 =AVERAGEIF(A2:A5,"<250000")
meet this condition, and their total is
300000.
Average of all property values less than
95000. Because there are 0 property values
that meet this condition, the AVERAGEIF #DIV/0! =AVERAGEIF(A2:A5,"<95000")
function returns the #DIV/0! error because
it tries to divide by 0.
Average of all commissions with a property
value greater than 250000. Two
24500 =AVERAGEIF(A2:A5,">250000",B2:B5)
commissions meet this condition, and their
total is 49000.

Page 5 of 9
Links between sheets and files.

You may want to use the value from a cell in another worksheet within the same workbook in a formula.
For example, the value of cell A1 in the current worksheet and cell A2 in the second worksheet can be
added using the format "sheetname!celladdress". The formula for this example would be
"=A1+Sheet2!A2" where the value of cell A1 in the current worksheet is added to the value of cell A2 in
the worksheet named "Sheet2".

a. Link Between Sheets


= ’[workbook1.xls]sheet1 ‘!A1
Workbook name[] worksheet cell reference
b. Link between files
=’C:\Document\Newfolder\[workbook12.xls]sheet1 ‘!A2
PATH Workbook name[] worksheet cell reference

3D-reference
A 3D-reference in Excel refers to the same cell or range on multiple worksheets. First, we'll look
at the alternative.
1. On the Company sheet, select cell B2 and type an equal sign =

2. Go to the North sheet, select cell B2 and type a +

3. Repeat step 2 for the Mid and South sheet by clicking on the shift

Page 6 of 9
Workshop IV

Ex 1:
1. Write the following 2 tables on the first worksheet

Table 1: Client Table 2: Articles


Code Name Code Description Unit Price
1 Aline 1 Hard disk $2,000.00
2 Simon 2 CDROM Drive $300.00
3 lara 3 Mouse $100.00
4 Chantal 4 Keyboard $250.00
5 Samar 5 Power Supply $500.00
6 Daniel 6 Camera $500.00
7 Elie 7 Screen $1,700.00
8 Sami
9 Rita
10 Joseph
2. In a second spreadsheet, use the following info:
a.The customer name is automatically entered according to the desired Client Code
b. Similarly for the description, this must be sought By Articles Code
c. The amounts are calculated automatically
d. The user should not enter a quantity more than 10
Code Client: 3
Client Name: lara

Invoice No. : 10

Code Article Description Quantity Unit Price Total


1 Harddisk 2 $2,000.00 $4,000.00
4 Keyboard 5 $250.00 $1,250.00
5 Power Supply 1 $500.00 $500.00
1 Harddisk 9 $2,000.00 $18,000.00
7 Screen 1 $1,700.00 $1,700.00
2 CDROM Drive 2 $300.00 $600.00
3 Mouse 6 $100.00 $600.00

Sub Total $26,650.00


TVA 10% $2,665.00

Nbre of articles 7 Total TTC $29,315.00

Page 7 of 9
Ex 2
Sheet1
Full Name Salary
Rima $350.00
Saideh $450.00
Rita $650.00
Joe $275.00
Rana $825.00
paula $1,000.00
Lina $600.00
Laura $700.00
Toni $5,500.00
Georges $400.00
Dani $3,500.00

Sheet 2
Nbre of
Full Name Salary Status Tax Bonus Salary Net
Kids
Rima M 3
Saideh S 0
Rita W 1
Joe D 3
Rana M 1
paula M 5
Lina D 0
Laura W 2
Toni S 1
Georges M 0
Dani M 2

Total
Minimum Nbre of kids
Maximum Nbre of kids
Nbre of Singles
SUM of salary that the status=S
SUM of salary that the status=W
SUM of salary that the status=D

Page 8 of 9
Questions

1. Salary must be automatically searched according to the entered name


2. Fill in the blanks of the tables above, taking into account the following constraints:
a. In TAX Cells:
i. IF the salary is <= $ 400 than TAX=3%
ii. If the salary is <= $ 800 than TAX=6%
iii. If the salary is> $ 800 than TAX=10%
b. In BONUS Cells:
i. If the status is S the bonus will be 1% of salary
ii. If the status is D the bonus will equal 1.5%
iii. If the status is M and the number of Kids exceeds 2, the bonus will be equal to 2%
iv. If the status is W the bonus will be equal to 2.5% of salary
v. If no one of the previous situations is valid then bonus = 0%
3. Use the necessary functions to calculate the results of the second table.

Page 9 of 9

You might also like