MS Excel Notes NMCP
MS Excel Notes NMCP
A spreadsheet comprises of a grid of cells, as shown in fig above. Each cell is accessed through a
unique address, called as cell address. The cell address comprises of Column Header followed by
Row Number. For example a cell at the intersection of Column D and Row 7 will be cell D7 (refer to
fig above).
Expressions
An expression is any entity that evaluates to a unique value (called as return value). An expression is
any valid combination of operands and operators (if required), that results in a unique value.
Expression begins with ‘=’ character.
Examples
=A1+B1
=12.5+7.12+8.9*13
=SIN(P6)-0.22
=(MAX(A1,B1,C1)+MIN(A1,B1,C1))/2
Note: To view expression Click FORMULAS Tab. This displays Formula Auditing Section. Click Show
Formulas.
Copy + Paste on FORMULA
Let us assume a worksheet as shown below has been created
=D7+2.5*E7-F7
Now to calculate values of D for rows 8 to 11 we can use one of the copy +paste techniques available
in MS Excel
Technique1: Click cell G7. Then move pointer to bottom right corner of the cell. A thin + sign
appears. Now drag mouse down to fill cells G8 to G11. These cells will now contain appropriate
formulas as shown below.
Technique 2: Click cell G7. Press Ctrl+C. Now select cells G8 to G11. Press Ctrl+V
Here, value of D is equal to A+2B-C. C has only one value (Cell F7). The cell G2 therefore contains a
formula =D7+2.5*E7-F7
If this formula is copied to next cell it automatically becomes =D8+2.5*E8-F8, but the required
formula is =D8+2.5*E8-F7.
To ensure that copy+paste works properly enter formula =D7+2.5*E7-$F$7 in cell G7.
Now to calculate values of D for rows 8 to 11 we can use one of the copy +paste techniques as
described earlier.
Here the cell address in the format $column$row_number is called as Absolute Address.
Mathematical Functions
Following is a list of some of the math functions available in MS Excel
Function Description
ABS function Returns the absolute value of a number
ACOS function Returns the arccosine of a number
ATAN function Returns the arctangent of a number
CEILING function Rounds a number to the nearest integer or to the nearest multiple of
significance
COS function Returns the cosine of a number
DEGREES function Converts radians to degrees
EVEN function Rounds a number up to the nearest even integer
EXP function Returns e raised to the power of a given number
FACT function Returns the factorial of a number
FLOOR function Rounds a number down, toward zero
INT function Rounds a number down to the nearest integer
LN function Returns the natural logarithm of a number
LOG function Returns the logarithm of a number to a specified base
LOG10 function Returns the base-10 logarithm of a number
MOD function Returns the remainder from division
ODD function Rounds a number up to the nearest odd integer
PI function Returns the value of pi
POWER function Returns the result of a number raised to a power
QUOTIENT function Returns the integer portion of a division
RADIANS function Converts degrees to radians
ROUNDDOWN Rounds a number down, toward zero
function
ROUNDUP function Rounds a number up, away from zero
SIGN function Returns the sign of a number
SIN function Returns the sine of the given angle
SQRT function Returns a positive square root
SUM function Adds its arguments
SUMIF function Adds the cells specified by a given criteria
SUMSQ function Returns the sum of the squares of the arguments
TAN function Returns the tangent of a number
TRUNC function Truncates a number to an integer
IF Function
The IF function is used for selectively executing expression(s) based on a logical expression/ test
condition. This function returns value of evaluated expression.
Syntax
Where
Enter data as shown above in cells BS1, BT1, BU1, BS2, BT2
=IF(BS2>BT2,BS2,BT2)
You can now change content of cells BS2 and BT2 to see if the IF() works
Exercise 1
Exercise to calculate Shear Force and Bending Moment at a given section for a SSB with a point load
as shown below.
Data required: W, a, l, x
Preparation and Data Entry – Prepare a worksheet and enter values of W, l, a, x as shown below
Calculation of b
b=l-a
=BX2-BY2
Calculation of Ra
Ra=W*b/l
Calculation of Rb
Rb=W-Ra
=BW2-CB2
Calculation of Fx
We know that
Referring to worksheet fig above, you can see that there are two cells titled Fx1 and Fx2
Cell titled Fx2 will hold value of Fx2 (used only for the case x=b)
=IF(BZ2<=CA2,-CC2,CB2)
=IF(BZ2=CA2,CB2,"")
Calculation of Mx
We know that
=IF(BZ2<=CA2,CC2*BZ2,CC2*BZ2-BW2*(BZ2-CA2))
To experiment, change value of x. Set value of x equal to value of b. The result will be as shown
below.
COUNT function
The COUNT function counts the numbers in the specified argument list or it counts cells in the
specified range that contain numbers. The list or range can contain data of different types. COUNT
function counts only numbers.
Syntax
Where, value1, value2, value3… is the list of item, cell reference, or range within which you want to
count numbers.
Note: When a list is specified arguments that are numbers, dates, or numbers enclosed within quotes
are counted. When a range is specified only numbers are counted.
Examples
=COUNT(12,Two,"Two") , returns 1
=COUNT(12,Two,"2") , returns 2
=COUNT(12,Two,"2","12/7/2019") , returns 3
=COUNT(K1:N3) , returns 7
COUNTIF function
COUNTIF function counts number of cells within a given range that meet specified criteria/ condition.
Syntax
COUNTIF(range, criteria)
Where, range is the area where to search for values, and criteria specifies what values to count.
e.g.
Examples
=COUNTIF(R1:R5,"Twenty") , returns 1
=COUNTIF(R1:R5,"*one") , returns 2
Note: “*” is a wildcard character. Here “*one” is treated as any text ending with “one”
=COUNTIF(R1:R5,"Twenty*") , returns 3
Note: Here “Twenty*” is treated as any text beginning with “Twenty”
=COUNTIF(U1:U7,5) , returns 2
=COUNTIF(U1:U7,">10") , returns 5
SUM Function
The SUM function in adds the values in the specified argument list or specified range. You can add
individual values, cell references or ranges or a mix of all three.
For example:
=SUM(5,3,10,20) , returns 28
=SUM(A1:F12), returns sum of all numbers in the range A1 to F12. Non numeric values are ignored.
SUMIF Function
Use the SUMIF function to sum the values in a range that meet criteria that you specify.
For example, suppose that in a column that contains numbers, you want to sum only the values that
are larger than 5. You can use the following formula: =SUMIF(B2:B25,">5").
If required, you can apply the criteria to one range and sum the corresponding values in a different
range. For example, the formula =SUMIF(B2:B5, "Valid", C2:C5) sums only the values in the range
C2:C5, where the corresponding cells in the range B2:B5 equal "Valid".
Syntax
Where,
criteria - The criteria in the form of a number, expression, a cell reference, text, or a function ( i.e. 56,
">32", B5, "32", "valid", TODAY() ).
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.
Note: 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.
The SUMIF function returns incorrect results when criteria string is longer than 255 characters. Though
preferable, the sum_range argument does not have to be of the same size and shape as the range
argument. The actual cells that are added is controlled by size and shape of range argument.
For example
1. If range is a1:c3, and sum_range is p1:r3, then values from p1:r3 will be added
2. If range is a1:c3, and sum_range is p1:r2, then values from p1:r3 will be added
3. If range is a1:c3, and sum_range is p1:t12, then values from p1:r3 will be added
Examples
Referring to figures above
=SUMIF(M1:P5,">40") , returns 762 (Sum of all values greater than 40 lying in the area M1:p5)
Where,
lookup_value - The value you want to look up, also called the lookup value.
table_array - The range where the lookup value is located. Remember that the lookup value should
always be in the first column in the range for VLOOKUP to work correctly.
col_index_no - The column number in the range that contains the return value. For example, if you
specify B2: D11 as the range, you should count B as the first column, C as the second, and so on.
match_type – Optional. You can specify TRUE if you want an approximate match or FALSE if you
want an exact match of the return value. If you don't specify anything, the default value will always
be TRUE or approximate match.
1. Let us say we want Amount spent on Sand, from the table above
Here “Sand” will be the lookup value. The value we want to find lies in column 2 of the range
AD1:AE7
=VLOOKUP(“Sand”,AD1:AE7,2) , returns 20000.00
2. Let us say we want Amount spent on item at Sr No 6, from the table above
Here 6 will be the lookup value. The value we want to find lies in column 3 of the range AC1:AE7
VLOOKUP to get Rate of item “Pipes, cables etc. exceeding 80 mm dia. but not exceeding 300 mm
dia.” will be
VLOOKUP(“Pipes, cables etc. exceeding 80 mm dia. but not exceeding 300 mm dia.”,AK1:AM13,2)
match_type = FALSE , returns exact match if available, else returns Value not available (#N/A) error.
Whereas =VLOOKUP(4.5,AC1:AE7,3,FALSE) , returns #N/A error as exact match for 4.5 is not
available
HLOOKUP Function
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. The H in HLOOKUP stands for "Horizontal."
Syntax
HLOOKUP(lookup_value, table_array, row_index_num, [match_type])
Where,
lookup_value - The value you want to look up, also called the lookup value.
table_array - The range where the lookup value is located. Remember that the lookup value should
always be in the first row in the range for HLOOKUP to work correctly.
row_index_no - The row number in the range that contains the return value.
match_type – Optional. You can specify TRUE if you want an approximate match or FALSE if you
want an exact match of the return value. If you don't specify anything, the default value will always
be TRUE or approximate match.
If match_type is TRUE, the values in the first row of table_array must be placed in ascending order
left to right: ...-2, -1, 0, 1, 2,... , A-Z, FALSE, TRUE; otherwise, HLOOKUP may not give the correct
value. If match_type is FALSE, table_array does not need to be sorted.
Note:
If HLOOKUP can't find lookup_value, and match_type 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.
If match_type is FALSE and lookup_value is text, you can use the wildcard characters, question mark
(?) and asterisk (*), in lookup_value. 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 (~) before the character.
Referring to fig above
=HLOOKUP("M35",BL3:BQ16,4)
Or
=HLOOKUP(BP3,BL:BQ16,4)
Given Data – Number of Bars, Bar Dia., Dimensions of section, Grade of Concrete
=PI()*AX3*AX3/4*AX2
=100*AX4/(AX5*AX6)
Referring to fig above – Table 19 from IS-456 has been entered in a worksheet as shown above. We
can use this data as explained below
To get the column number for given grade from the range BC4:BH4
To get column number for given grade, enter following expression in cell AX10
=HLOOKUP(AX8,BC3:BH4,2,TRUE)
This returns 5, which is the column containing Tc values for M30 grade (Refer to Table 19 above)
To check if HLOOKUP() is working properly, change grade in cell AX6, the value in cell AX10 should
change accordingly.
To get row numbers for particular percentage of steel we can use VLOOKUP. VLOOKUP with
match_type set to FALSE is useful when exact match is available. As in our case exact match is less
likely we must set match_type to TRUE. This will match with a value of pt that is just less than or
equal to the specified value (lookup value) of pt
Use VLOOKUP over BA5:BB17, to get row number for max pt <= given lookup value (0.63), as below
=VLOOKUP(0.63,BA5:BB17,2,TRUE)
Referring to fig above, we can see that this will return 3
Adding 1 to this return value will give us next row number. These two rows are needed for
interpolating value of Tc
=VLOOKUP(AX7,BA5:BH17,2,TRUE)
To get rU, enter following expression in cell AX14
=AX13+1
Now we can get values of Tc corresponding to these rows and required grade of concrete
=VLOOKUP(AX13,BB5:BH17,AX10,FALSE)
=VLOOKUP(AX14,BB5:BH17,AX10,FALSE)
Alternatively we can use following HLOOKUP() expressions in cells AX17 and AX18 respectively
=HLOOKUP(AX8,BC3:BH17,AX13+2,FALSE)
=HLOOKUP(AX8,BC3:BH17,AX14+2,FALSE)
To get values of pt corresponding to rL and rU
=VLOOKUP(AX13,AZ5:BA17,2,FALSE)
=VLOOKUP(AX14,AZ5:BA17,2,FALSE)
ptW=ptU-ptL
ptD=pt-ptL
TcW=TcU-TcL
Tc=TcL+TcW x ptD/ptW
Referring to fig above, enter text in cells AW24, AW25, AW26, AW27, AW28
Now enter following expressions in cells AX25, AX26, AX27, AX28 respectively
=AX22-AX21 (ptW=ptU-ptL)
=AX7-AX21 (ptD=pt-ptL)
=AX18-AX17 (TcW=TcU-TcL)