iipm chapter 1
Post on 11-Nov-2014
1.120 Views
Preview:
DESCRIPTION
TRANSCRIPT
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 1 of 20
F
Chapter
1
Formulas and Functions
What is a formula?
ormula is an equation that performs operations on worksheet data. Formulas can
perform mathematical operations, such as addition and multiplication, or they can
compare worksheet values or join text. Fo rmulas can refer to other cells on the
same worksheet, cells on other sheets in the same workbook, or cells on sheets in
other workbooks.
Constructing a Formula (Syntax)
Formulas calculate values in a specific order. A formula in Microsoft Excel always
be gins with an equal sign (=). The equal sign tells Excel that the succeeding characters
constitute a formula. Following the equal sign are the elements to be calculated (the
operands), which are separated by calculation operators. Excel calculates the formu la
from left to right, according to a specific order for each operator in the formula. You can
change the order of operations by using parentheses.
Cell and Range References
A formula can refer to constant values and to other cells. The cell that contains the
formula is known as a dependent cell when its value depends on the values in other cells.
For example, cell B2 is a dependent cell if it contains the formula =C2.
Whenever a cell that the formula refers to changes, the dependent cell also changes,
by default. For example, if a value in any of the following cells changes, the result of
the formula =B2+C2+D2 also changes.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 2 of 20
F
A reference identifies a cell or a range of cells on a worksheet and tells Microsoft Excel
where to look for the values or data you want to use in a formula. With references, you can
use data contained in different parts of a worksheet in one formula or use the value from
one cell in several formulas. You can also refer to cells on other sheets in the same
workbook, to other workbooks, and to data in other programs. References to cells in other
workbooks are called external references.
Cell/Range to refer to Use
The cell in column A and row 10 A10
The range of cells in column A and rows 10 through 20
The range of cells in row 15 and columns B through E
A10:A20
B15:E15
All cells in row 5 5:5
All cells in rows 5 through 10 5:10
All cells in column H H:H
All cells in columns H through J H:J
The range of cells in columns A through E and rows 10 through 20
A10:E20
What is a function?
unctions are predefined formulas that perform calculations by using specific values, called arguments, in a particular order, or structure.
Arguments Arguments can be numbers, text, logical values such as TRUE or
FALSE, arrays, error values such as #N/A, or cell references. The argument you
designate must produce a valid value for that argument. Arguments can also be constants,
formulas, or other functions.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 3 of 20
n:
Logical Functions
These comprise of AND, OR, IF, NOT functions.
AND Function:
Returns TRUE if all its arguments are TRUE; returns FALSE if one or more arguments is
FALSE.
Syntax
AND(logical1,logical2, ...)
Logical1, logical2, ... are 1 to 30 conditions you want to test that can be either TRUE or
FALSE.
• The arguments m ust evaluate to logical values such as TRUE or FALSE, or the
arguments must be arrays or references that contain logical values.
• If an array or reference argument contains text or empty cells, those values are
ignored.
• If the specified range contains no lo gical values, AND returns the #VALUE! error
value.
AND(TRUE, TRUE) equals TRUE
AND(TRUE, FALSE) equals FALSE
♠Worksheet Example
To analyze if a person is working in D shift and is handling less than 5 contacts.
Comment [J1]: Instructor
Actio Explain Several other
combinations of AND ALSO.
No. of Contacts
Agent Name Handled
Shift (N/D)
Result
Formula Used
Ramesh 2 D TRUE AND(C2="d",B2<5) Rakesh 16 D FALSE Gaurav 12 N FALSE Arjun 6 D FALSE
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 4 of 20
OR Function:
Returns TRUE if any argument is TRUE; returns FALSE if all arguments are FALSE.
Syntax
OR(logical1,logical2,...)
Logical1,logical2,... are 1 to 30 conditions you want to test that can be either TRUE or
FALSE.
• The arguments must evaluate to logical values such as TRUE or FALSE, or in
arrays or references that contain logical values.
• If an array or reference argument contains text or empty cells, those values are
ignored.
• If the specified range contains no logical values, OR returns the #VALUE! error
value.
Examples
OR(TRUE) equals TRUE
If A1:A3 contains the values TRUE, FALSE, and TRUE, then:
OR(A1:A3) equals TRUE
♠Worksheet Example
To analyse if person is working in N shift or is handling more than 5 contacts.
Comment [J2]: Explain difference between AND, OR
No. of Contacts
Agent Name Handled
Shift (N/D)
Result
Formula Used
Ramesh 2 D FALSE OR(C2="N",B2>5) Rakesh 16
Gaurav 12 D
N TRUE
TRUE
Arjun 6 D TRUE
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 5 of 20
IF Function:
Returns one value if a condition you specify evaluates to TRUE and another value if it
evaluates to FALSE.
Use IF to conduct conditional tests on values and formulas.
Syntax
IF(logical_test,value_if_true ,value_if_false)
Logical_test is any value or expression that can be evaluated to TRUE or FALSE. For
example, A10=100 is a logical expression; if the value in cell A10 is equal to 100, the
expression evaluates to TRUE. Otherwise, the expression evaluates to FALSE. This
argument can use any compar ison calculation operator.
IF cell E5 contains the value 10, then the formula =IF(E5=10,”YES”,”NO”) would give
the output as YES if the value in cell E5 is changed to be not equal to 10 then the formula
output would be NO.
Value_if_true is the value that is returned if logical_test is TRUE. For example, if this
argument is the text string "Within budget" and the logical_test argument evaluates to
TRUE, then the IF function displays the text "Within budget". If logical_test is TRUE
and value_if_true is blank, this argument returns 0 (zero). To display the word TRUE,
use the logical value TRUE for this argument. Value_if_true can be another formula.
Value_if_false is the value that is returned if logical_test is FALSE. For example, if this
argument is the text string "Over budget" and the logical_test argument evaluates to
FALSE, then the IF function displays the text "Over budget". If logical_test is FALSE
and value_if_false is omitted, (that is, after value_if_true, there is no comma), then the
logical value FALSE is returned. If logical_test is FALSE and value_if_false is blank
(that is, after value_if_true, there is a comma followed by the closing parenthesis), then
the value 0 (zero) is returned. Value_if_false can be another formula.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 6 of 20
♠Worksheet Example
To calculate the Wages @Rs. 100 per hour for employees who work in N shift and have
worked greater than 5 hours.
Shift
Agent Name (N/D)
No. of Hours Worked
Result
Formula Used
Ramesh N 6 600 IF(AND(C2="N",D2>5),D2*100,0) Rakesh D 4 0 Gaurav N 7 700 Arjun D 7 0 Chetna N 5 0
• Up to seven IF functions can be nested as value_if_true and value_if_false
arguments to construct more elaborate tests.
♠Worksheet Example
To calculate the Wages @Rs.100 per hour for employees who work in D shift and
@Rs.150 for those employees who work in the night shift but have worked for greater
than 5 hours.
Comment [J3]: Explain the concept of NESTED IF
Shift Agent Name (N/D)
No. of Hours Worked
Result
Formula Used
Ramesh N 6 900 IF(B2="D",C2*100,IF(C2>5,C2*150,"NO OT")) Rakesh D 4 400 Gaurav N 7 1050 Arjun D 7 700 Chetna N 5 NO OT
• Microsoft Excel provides additional functions that can be used to analyze your
data based on a condition. For example, to count the number of occurrences of a
string of text or a number within a range of cells, use the COUNTIF worksheet
function. To calculate a sum based on a string of text or a number within a range,
use the SUMIF worksheet function.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 7 of 20
Conditional Counting and Summing Using a Single Condition
In many cases, you don't want to count or sum all of the records. Rather, you want to
focus on records that meet a certain condition, for example, only the sales made by a
sales representative. Use the COUNTIF and SUMIF functions to return these types of
results. CounCounCounCountttt ththththeeee NumbeNumbeNumbeNumberrrr ooooffff SaleSaleSaleSalessss MadMadMadMadeeee bbbbyyyy aaaa SaleSaleSaleSalessss RepreseRepreseRepreseRepresentativentativentativentative The following formula is a straightforward use of the COUNTIF function. It counts the sales made by Jones:
� =COUNTIF(A2:A13,"Jones")
CounCounCounCountttt ththththeeee NumbeNumbeNumbeNumberrrr ooooffff SaleSaleSaleSalessss MadMadMadMadeeee bbbbyyyy OtheOtheOtheOtherrrr SaleSaleSaleSalessss RepresentativesRepresentativesRepresentativesRepresentatives This formula counts all the sales not made by Jones:
� =COUNTIF(A2:A13,"<>Jones")
CounCounCounCountttt ththththeeee NumbeNumbeNumbeNumberrrr ooooffff SaleSaleSaleSalessss GreateGreateGreateGreaterrrr thathathathannnn aaaa TargeTargeTargeTargetttt ValueValueValueValue This formula counts the number of sales in C2:C13 that are greater than a target value. In
this example, the target value would have to be entered into D1. This COUNTIF function
accepts a cell reference in the second argument. Also, notice that this formula uses the
concatenation operator (&) to join the greater than symbol (>) with the cell reference.
� =COUNTIF(C2:C13,">"&D1)
CounCounCounCountttt ththththeeee NumbeNumbeNumbeNumberrrr ooooffff SaleSaleSaleSalessss GreateGreateGreateGreaterrrr thathathathannnn ththththeeee SaleSaleSaleSalessss AAAAverageverageverageverage This formula returns the number of sales that exceed the average sales amount. This
formula also shows that you can use a function as the second argument for COUNTIF:
� =COUNTIF(C2:C13,">"&AVERAGE(C2:C13))
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 8 of 20
Conditional Summing
The SUMIF function is similar to COUNTIF, but it uses an additional argument. The first
argument refers to the range that is being evaluated, the second argument represents the
criteria, and the third argument is the range to be summed.
AddAddAddAdd UpUpUpUp SalesSalesSalesSales inininin aaaa GivenGivenGivenGiven MonthMonthMonthMonth This formula adds up all the sales in January:
� =SUMIF(B2:B13,"=Jan",C2:C13)
As with the COUNTIF function, an "equal to" condition is assumed if the comparison
operator is omitted. The preceding formula could have been written as:
=SUMIF(B2:B13,"=Jan",C2:C13). AdAdAdAddddd UUUUpppp SaleSaleSaleSalessss MadMadMadMadeeee bbbbyyyy OtheOtheOtheOtherrrr SaleSaleSaleSalessss RepRepRepRepresentativesresentativesresentativesresentatives
This formula adds up the sales made by sales representatives other than Rogers. It uses a
"not equal to" comparison: � =SUMIF(A2:A13,"<>Rogers",C2:C13)
AddAddAddAdd UpUpUpUp thethethethe SalesSalesSalesSales GreaterGreaterGreaterGreater thanthanthanthan aaaa CertainCertainCertainCertain ValueValueValueValue This formula adds up all the values that are greater than 500. In this formula, the
condition being evaluated is based on the same range that is being summed:
� =SUMIF(C2:C13,">500",C2:C13)
Note: The COUNTIF and SUMIF functions can also use wildcard comparison characters.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 9 of 20
Conditional Counting and Summing Using Multiple Conditions
The formulas in the section return counts or sums based on two or more conditions. CounCounCounCountttt ththththeeee NumbeNumbeNumbeNumberrrr ooooffff MonthMonthMonthMonthssss aaaa SaleSaleSaleSalessss RepresentativRepresentativRepresentativRepresentativeeee MadMadMadMadeeee aaaa SaleSaleSaleSale This formula counts the number of times Jones made sales in February. It is a conditional
counting formula that uses two conditions.
� =SUMPRODUCT((A2:A13="Jones")*(B2:B13="Feb"))
CounCounCounCountttt MonthMonthMonthMonthssss WheWheWheWhennnn SaleSaleSaleSalessss ArArArAreeee GreateGreateGreateGreaterrrr thathathathannnn aaaa SpecifiSpecifiSpecifiSpecificccc AmountAmountAmountAmount You can use a formula similar to the one above to work with numeric data. This formula
returns the number of rows in which the month is January and the amount is greater than
200.
� =SUMPRODUCT((B2:B13="Jan")*(C2:C13>200))
CounCounCounCountttt ththththeeee NumbeNumbeNumbeNumberrrr ooooffff SaleSaleSaleSalessss thathathathatttt ArArArAreeee BetweeBetweeBetweeBetweennnn SpecifiSpecifiSpecifiSpecificccc ValuesValuesValuesValues This formula counts the number of times the sales amount falls between two 200 and 500. The formula uses two conditions: the amount greater than or equal to 200, and the
amount less than or equal to 500.
� =SUMPRODUCT((C2:C13>=200)*(C2:C13<=500))
CountCountCountCount thethethethe NumberNumberNumberNumber ofofofof SalesSalesSalesSales BasedBasedBasedBased onononon ThrThrThrThreeeeeeee ConditionsConditionsConditionsConditions This formula returns the amount when the sales representative is Jones, the month is
February, and the amount is greater than 500. This function uses a single argument,
which consists of three logical expressions multiplied together. The resul t is the sum of
these products.
� =SUMPRODUCT((A2:A13="Jones")*(B2:B13="Feb")*(C2:C13>500))
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 10 of 20
AddAddAddAdd UpUpUpUp aaaa RepresentativeRepresentativeRepresentativeRepresentative’’’’ ssss SalesSalesSalesSales inininin OneOneOneOne MonthMonthMonthMonth The formula below adds up sales amount based on two conditions: when the sales
representative is Jones and the month is February.
� =SUMPRODUCT((A2:A13="Jones")*(B2:B13="Feb")*(C2:C13))
AdAdAdAddddd ththththeeee CombineCombineCombineCombinedddd SaleSaleSaleSalessss fofofoforrrr TwTwTwTwoooo SaleSaleSaleSalessss RepresentativesRepresentativesRepresentativesRepresentatives
The formula below returns the sum of the sales amount for both Jones and Rogers. This
formula uses a single argument and consists of three expressions. Notice, however, that
the first two arguments are not multiplied as in the previous examples. Because we are
doing a logical OR comparison, they are summed. Summing two logical values results in a value of 1 when either of the expressions is TRUE.
� =SUMPRODUCT(((A2:A13="Jones")+(A2:A13="Rogers"))*(C2:C13))
NOT Function:
Reverses the value of its argument. Use NOT when you want to make sure a value is not
equal to one particular value.
Syntax
NOT(logical )
Logical is a value or expression that can be evaluated to TRUE or FALSE. If logical is
FALSE, NOT returns TRUE; if logical is TRUE, NOT returns FALSE.
Examples
NOT(FALSE) equals TRUE
NOT(1+1=2) equals FALSE
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 11 of 20
Lookup Functions
Returns a value either from a one-row or one -column range or
from an array. The LOOKUP function has two syntax forms:
vector and array. The vector form of LOOKUP looks in a one-
row or one-column range (known as a vector) for a value and
returns a value from the same position in a second one-row or
one -column range. The array form of LOOKUP looks in the
first row or column of an array for the specified value and
returns a value from the same position in the last row or column
of the array.
First Confirm if you have Look Up Wizard installed on your
machine,
Tools� Addins� Check � Lookup Wizard � OK.
Now we will see how a Lookup Function works. Go to the Tools Menu� Wizard�
Lookup.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 12 of 20
Step 1 � Choose the source data range here.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 13 of 20
Step 2� Enter the column you want to find the value from and the row label for the
row that you want to find the value for.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 14 of 20
Step 3:
Choose
The
Options
for
pasting
the
formula
results.
Choose Destination cells for other
data also.
Final Step: Click Finish
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 15 of 20
Final Output (Results of Lookup):
No. of Contacts Handled Shelly Chatterjee
27
HLOOKUP
Searches for a value in the top row of a table or an array of values, and then returns a
value in the same column from a row you specify in the table or array. Use HLOOKUP
when your comparison values are located in a row across the top of a table of data, and
you want to look down a specified number of rows. Use VLOOKUP when your
comparison values are located in a column to the left of the data you want to find.
Syntax
HLOOKUP (lookup_value ,table_array,row_index_num,range_lookup)
Lookup_value is the value to be found in the first row of the table. Lookup_value can be
a value, a reference, or a text string.
Table_array is a table of information in which data is looked up. Use a reference to a
range or a range name.
• The values in the first row of table_array can be text, numbers, or logical values.
• If range_lookup is TRUE, the values in the first row of table_array must be placed
in ascending order: ...-2, -1, 0, 1, 2,... , A-Z, FALSE, TRUE; otherwise,
HLOOKUP may not give the correct value. If range_lookup is FALSE,
table_array does not need to be sorted.
• Uppercase and lowercase text are equivalent.
• You can put values in ascending order, left to right, by selecting the values and
then clicking Sort on the Data menu. Click Options , click Sort left to right , and
then click OK. Under Sort by, click the row in the list, and then click Ascending .
Row_index_num is the row number in table_array from which the matching value will
be returned. A row_index_num of 1 returns the first row value in table_array, a
row_index_num of 2 returns the second row value in table_array, and so on. If
row_index_num is less than 1, HLOOKUP returns the #VALUE! error value; if
row_index_num is greater than the number of rows on table_array, HLOOKUP returns
the #REF! error value.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 16 of 20
Range_lookup is a logical value that specifies whether you want HLOOKUP to find an
exact match or an approximate match. If TRUE or omitted, an approximate match is
returned. In other words, if an exact match is not found, the next largest value that is less
than lookup_value is returned. If FALSE, HLOOKUP will find an exact match. If one is
not found, the error value #N/A is returned.
Remarks
• If HLOOKUP can't find lookup_value, and range_lookup is TRUE, it uses the
largest value that is less than lookup_value.
• If lookup_value is smaller than the smallest value in the first row of table_array,
HLOOKUP returns the #N/A error value.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 17 of 20
VLOOKUP
Searches for a value in the leftmost column of a table, and then returns a value in the
same row from a column you specify in the table. Use VLOOKUP instead of HLOOKUP
when your comparison values are located in a column to the left of the data you want to
find.
Syntax
VLOOKUP (lookup_value ,table_array,col_index_num,range_lookup)
Lookup_value is the value to be found in the first column of the array. Lookup_value
can be a value, a reference, or a text string.
Table_array is the table of information in which data is looked up. Use a reference to a
range or a range name, such as Database or List.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 18 of 20
• If range_lookup is TRUE, the values in the first column of table_array must be
placed in ascending order: ..., -2, -1, 0, 1, 2, ..., A-Z, FALSE, TRUE; otherwise
VLOOKUP may not give the correct value. If range_lookup is FALSE,
table_array does not need to be sorted.
• You can put the values in ascending order by choosing the Sort command from
the Data menu and selecting Ascending.
• The values in the first column of table_array can be text, numbers, or logical
values.
• Uppercase and lowercase text are equivalent.
Col_index_num is the column number in table_array from which the matching value
must be returned. A col_index_num of 1 returns the value in the first column in
table_array; a col_index_num of 2 returns the value in the second column in table_array, and
so on. If col_index_num is less than 1, VLOOKUP returns the #VALUE! error value;
if col_index_num is greater than the number of columns in table_array, VLOOKUP
returns the #REF! error value.
Range_lookup is a logical value that specifies whether you want VLOOKUP to find an
exact match or an approximate match. If TRUE or omitted, an approximate match is
returned. In other words, if an exact match is not found, the next largest value that is less
than lookup_value is returned. If FALSE, VLOOKUP will find an exact match. If one is
not found, the error value #N/A is returned.
Remarks
• If VLOOKUP can't find lookup_value, and range_lookup is TRUE, it uses the
largest value that is less than or equal to lookup_ value.
• If lookup_value is smaller than the smallest value in the first column of
table_array, VLOOKUP returns the #N/A error value.
• If VLOOKUP can't find lookup_value, and range_lookup is FALSE, VLOOKUP
returns the #N/A value.
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 19 of 20
Access the VLOOKUP function from the Functions Menu.
This is the VLOOKUP function run on the Agent Daily data function.
Paste Special
Advanced Excel – Version 1.2 Updated Jan 10, 2010 - IIPM
All rights reserved. Material Designed by Rahul Kumar Kandoi.
Page 20 of 20
Paste
Formulas Pastes Only Formulas as entered in the formula bar.
Values Pastes Only the Values as displayed in the cell.
Formats Pastes Only cell formatting.
Comments Pastes only comments attached to the cells
Validation Pastes Data Validation rules for the copied cells to the Paste Area.
All Except Borders Pastes all cell contents and formatting applied to the cells except
for cell borders.
Column Widths Pastes the width of one column to another column.
Operation
Add
Subtract
Multiply
Divide
Specifies, which
mathematical operation if
any you want to apply to
the copied data.
Skip Blanks Avoids replacing values in your Paste area when blank cells occur
in the copy area.
Transpose Changes columns of copied data to rows, and vice versa.
Paste Link Links the pasted data to the active worksheet.
Copy only visible cells
If there are hidden cells, rows, or columns on your worksheet, you can copy only the
visible cells — for example, you can copy only the displayed summary data on an
outlined worksheet.
1. Select the cells you want to copy.
2. On the Edit menu, click Go To .
3. Click Special.Click Visible cells only, and then click OK.Click Copy.
4. Select the upper-left cell of the pas te area.
5. Click Paste.
top related