MS Excel Formulas: Cell References, IF, VLOOKUP, ROUND and Charts
MS Excel is the spreadsheet program used in almost every office, so computer operator, data entry, clerk and assistant papers regularly ask what a formula returns on a small table, how a reference changes when a formula is copied and which chart suits a set of data. These questions reward working the formula out step by step rather than memorising. This lesson covers the core functions that work the same way in every modern version of Excel, with each result checked by calculation.
Asked in: PPSC, FPSC, NTS, ETEA, KPPSC, SSC, IBPS and ICS/ECAT computer
Formulas, operators and order of calculation
A formula always starts with an equals sign and can mix numbers, cell references, operators and functions, for example =B2+C2 or =SUM(B2:B6). When you change a value in a referenced cell, every formula that uses it recalculates automatically.
In this lesson multiplication is written as × and division as ÷ or a slash; in Excel you type the asterisk key for × and the forward slash for ÷. Comparisons are written as ≥, ≤ and ≠; in Excel you type ≥ as the greater-than sign followed by the equals sign, ≤ as the less-than sign followed by the equals sign, and ≠ as the less-than sign followed by the greater-than sign.
Excel follows the usual order: brackets first, then powers, then multiplication and division from left to right, then addition and subtraction from left to right. So =20-8/4×2 gives 16, because 8/4×2 = 4 is worked out before the subtraction. Brackets change the order: =(20-8)/4×2 gives 6.
- Every formula begins with =
- Order: brackets → powers → × and ÷ (left to right) → + and − (left to right)
- =20-8/4×2 = 16, but =(20-8)/4×2 = 6
- Type × as the asterisk key and ÷ as the forward slash
Relative, absolute and mixed cell references
A cell address such as B3 is made of a column letter and a row number. A range is written with a colon between its corners: B2:D5 covers columns B, C and D and rows 2 to 5, which is 3 × 4 = 12 cells.
A relative reference (plain B3) changes when the formula is copied. Excel remembers the position relative to the formula cell, so copying a formula one row down adds 1 to every relative row number, and copying it two columns right moves every relative column letter two places along.
An absolute reference locks both the column and the row by putting a dollar sign before each of them, before the B and before the 3. It points to the same cell wherever the formula is copied, which is what you want for a single rate, price or total kept in one cell. A mixed reference locks only one part: a dollar sign before the column letter keeps the column fixed but lets the row change, and a dollar sign before the row number keeps the row fixed but lets the column change. Pressing F4 while editing a reference cycles through these four forms.
- Relative (B3): column and row both change on copying
- Absolute (dollar before B and before 3): nothing changes
- Mixed, column locked: column fixed, row changes
- Mixed, row locked: row fixed, column changes
- Cells in a range = number of columns × number of rows
Everyday functions: SUM, AVERAGE, COUNT, COUNTA, MAX, MIN, ROUND
A function is a built-in formula with a name and arguments in brackets. SUM adds numbers, AVERAGE finds their arithmetic mean, MAX and MIN return the largest and smallest values. Arguments can be single cells, ranges or plain numbers separated by commas, so =SUM(A1:A3, 10) adds the three cells and then 10.
SUM, AVERAGE, MAX and MIN skip blank cells and text inside a range, but a cell containing 0 is a number and is included. This matters for AVERAGE: 6, 0 and 12 average to 6 because the zero is counted, while a blank cell would not be counted at all. COUNT counts only the cells that contain numbers, whereas COUNTA counts every cell that is not empty, text included.
ROUND(number, digits) rounds to the stated number of decimal places, with 5 and above rounding up. A digits value of 0 rounds to a whole number, and a negative value rounds to the left of the decimal point: ROUND(3567, -2) gives 3600, the nearest hundred. ROUND changes the stored value, unlike formatting buttons that only change how many decimals are displayed.
- SUM, AVERAGE, MAX, MIN: ignore blanks and text, include zeros
- COUNT: cells with numbers; COUNTA: all non-empty cells
- ROUND(48.736, 1) = 48.7; ROUND(48.736, 0) = 49
- ROUND(x, −1) → nearest ten; ROUND(x, −2) → nearest hundred
Decisions and lookups: IF, COUNTIF and VLOOKUP
IF(test, value if true, value if false) checks a condition and returns one of two results. =IF(B2 ≥ 40, "Pass", "Fail") shows Pass for a score of exactly 40, because 40 ≥ 40 is true. IF functions can be nested to give more than two results, for example =IF(B2 ≥ 80, "A", IF(B2 ≥ 60, "B", "C")); Excel checks the conditions in order and stops at the first one that is true. Text results are written inside double quotes.
COUNTIF(range, criterion) counts the cells in a range that meet one condition, such as =COUNTIF(C2:C7, "Lahore"). SUMIF(range, criterion, sum range) adds the matching values from another column.
VLOOKUP(lookup value, table, column number, FALSE) searches for the lookup value in the first column of the table and returns the value from the stated column of the same row. Column number 1 is the table’s own first column, 2 is the next one, and so on. FALSE asks for an exact match; if the value is not found the result is the #N/A error. VLOOKUP can only look to the right of the first column, so the column you search must be the leftmost one in the table range.
- IF(test, if true, if false)
- Nested IF: conditions checked in order, first true one wins
- COUNTIF(range, criterion) counts matches
- VLOOKUP(value, table, column number, FALSE): exact match in first column
- VLOOKUP value not found (exact match) → #N/A
Error values
When Excel cannot calculate a formula it shows an error value starting with #. #DIV/0! means a number was divided by zero or by an empty cell. #NAME? means Excel does not recognise a name in the formula, usually a misspelt function such as SUMM, or text typed without quotes. #N/A means a value is not available, typically a lookup value that VLOOKUP cannot find.
#REF! means the formula refers to a cell that is no longer valid, for example after the row containing it was deleted. #VALUE! means an argument is the wrong type, such as trying to add a number to a word. A cell full of # symbols (#####) is not an error in the formula at all; the column is simply too narrow to show the number.
- #DIV/0!: division by zero or a blank cell
- #NAME?: unknown function or name, often a spelling mistake
- #N/A: lookup value not found
- #REF!: invalid or deleted cell reference
- #VALUE!: wrong type of argument, e.g. text in arithmetic
Choosing the right chart
A column chart (vertical bars) or bar chart (horizontal bars) compares values across categories, such as the sales of five branches. A line chart shows a trend over time, such as monthly rainfall across a year, because the line joins points in order.
A pie chart shows how parts make up one whole, such as each department’s share of a budget; it works with a single data series and only a few slices. A scatter (XY) chart plots pairs of numbers to show whether two variables are related, such as hours studied against marks obtained. An area chart is a line chart with the space below filled, emphasising the size of totals over time.
- Column or bar: compare categories
- Line: trend over time
- Pie: parts of one whole (one data series)
- Scatter (XY): relationship between two numeric variables
Solved examples
- Cells B2 to B6 hold the marks of Ali 72, Priya 85, Hamza 64, Neha 90 and Bilal 59. Find =SUM(B2:B6), =AVERAGE(B2:B6) and =MAX(B2:B6)-MIN(B2:B6).
- SUM adds the five marks: 72 + 85 + 64 + 90 + 59 = 370.
- AVERAGE divides the total by the count of numbers: 370 ÷ 5 = 74.
- MAX is 90 and MIN is 59, so the difference is 90 − 59 = 31.
Answer: SUM = 370, AVERAGE = 74, MAX − MIN = 31 - Ayesha keeps sales of Rs 40,000, Rs 25,000 and Rs 60,000 in B2 to B4 and a commission rate of 5% in E1. In C2 she enters =B2×E1 with E1 locked as an absolute reference (dollar signs before E and before 1) and copies it to C3 and C4. What do C2, C3 and C4 show, and what would go wrong if E1 were left relative?
- With E1 locked, the copies become =B3×E1 and =B4×E1, while the B reference moves down as a relative reference.
- C2 = 40,000 × 5% = 2,000; C3 = 25,000 × 5% = 1,250; C4 = 60,000 × 5% = 3,000.
- If E1 were relative, copying one row down would change it to E2 and then E3. Those cells are empty, so C3 and C4 would show 0.
Answer: C2 = 2,000, C3 = 1,250, C4 = 3,000; a relative E1 would give 0 in C3 and C4 - Ravi builds a multiplication table. A2 to A5 hold 2, 3, 4, 5 and B1 to E1 hold 2, 3, 4, 5. In B2 he types =A2×B1, locking only the column of A2 (dollar sign before A) and only the row of B1 (dollar sign before 1). He copies B2 to every cell up to E5. What formula and value appear in D4?
- From B2 to D4 the formula moves 2 columns right and 2 rows down.
- In the first reference the column A is locked and the row is free, so A2 becomes A4.
- In the second reference the row 1 is locked and the column is free, so B1 becomes D1.
- D4 therefore contains =A4×D1 with the same locks, which is 4 × 4 = 16.
Answer: D4 holds A4 × D1 (column A and row 1 locked), giving 16 - Using the marks from the first example in B2 to B6 (72, 85, 64, 90, 59), what does =IF(B2 ≥ 60, "Pass", "Fail") show when copied down, and what does the grade formula =IF(B2 ≥ 80, "A", IF(B2 ≥ 60, "B", "C")) give for each student?
- Pass/Fail: only 59 is below 60, so the results are Pass, Pass, Pass, Pass, Fail.
- Grade: 72 fails the first test (not ≥ 80) but passes the second, so B; 85 is A; 64 is B; 90 is A.
- 59 fails both tests, so the final value C is returned.
Answer: Pass, Pass, Pass, Pass, Fail; grades B, A, B, A, C - Range A2:C6 holds IDs 101 to 105 in column A, names Sana, Arjun, Usman, Kavya, Zainab in column B and cities Lahore, Pune, Multan, Jaipur, Quetta in column C. Find =VLOOKUP(104, A2:C6, 2, FALSE), =VLOOKUP(102, A2:C6, 3, FALSE) and =VLOOKUP(108, A2:C6, 2, FALSE).
- VLOOKUP searches the first column (the IDs). 104 is in the fourth row of the table; column 2 of that row is the name Kavya.
- 102 is in the second row; column 3 of that row is the city Pune.
- 108 does not exist in the ID column, and FALSE demands an exact match, so the result is the #N/A error.
Answer: Kavya, Pune and #N/A - Find =ROUND(2468.375, 1), =ROUND(2468.375, 0) and =ROUND(2468.375, -2). Then, if C2 to C7 hold Lahore, Delhi, Lahore, Karachi, Lahore, Delhi, find =COUNTIF(C2:C7, "Lahore").
- One decimal place: the digit after the 3 is 7, so round up to 2468.4.
- Zero decimal places: the first decimal digit is 3, so round down to 2468.
- Digits −2 rounds to the nearest hundred: 2468.375 lies between 2400 and 2500 and the tens digit is 6, so it becomes 2500.
- COUNTIF counts the cells equal to Lahore: positions 1, 3 and 5, which is 3.
Answer: 2468.4, 2468, 2500 and COUNTIF = 3
Exam shortcuts
- For any copy question, first write down how many rows and columns the formula moves, then change only the unlocked parts by exactly that amount.
- A dollar sign locks the part written immediately after it: before the letter it locks the column, before the number it locks the row.
- Before averaging, cross out blanks and text but keep zeros, then divide by how many numbers remain.
- In VLOOKUP, count the column number from the first column of the table range, not from column A of the sheet.
- Test the boundary value in IF questions: a score exactly equal to the limit passes a ≥ test but fails a strict greater-than test.
- Match the chart to the question: share of a whole means pie, change over time means line, comparing categories means column or bar, relationship means scatter.
Common mistakes
- Leaving a rate or total cell relative, so the copied formulas point at empty cells and show 0.
- Dividing by the total number of cells in AVERAGE questions, including blank or text cells that Excel ignores.
- Counting the VLOOKUP column number from column A of the worksheet instead of from the first column of the given range.
- Ignoring the order of operations and working a formula strictly from left to right.
- Thinking ##### is a formula error; it only means the column is too narrow.
Practice MCQs
- Which type of cell reference changes both its column and its row when a formula is copied to another cell?
A) Absolute reference
B) Relative reference
C) Mixed reference
D) Circular reference
Answer: B) Relative reference — A relative reference such as B3 adjusts both parts to keep the same position relative to the formula. An absolute reference changes neither part, a mixed reference changes only the unlocked part, and a circular reference is a formula that refers to its own cell, which has nothing to do with copying. - Saima wants to show what share of the annual budget each of five departments receives. Which chart type is most suitable?
A) Pie chart
B) Scatter chart
C) Area chart
D) Line chart
Answer: A) Pie chart — A pie chart shows how the parts of one whole compare, which is exactly a share of a budget. A line or area chart is used for change over time, and a scatter chart shows the relationship between two sets of numbers. - Rahul enters 5, 15 and 20 in A1, A2 and A3, then types =SUM(A1:A3, 10) in A4. What appears in A4?
A) 35
B) 40
C) 50
D) 10
Answer: C) 50 — SUM adds every argument: the range gives 5 + 15 + 20 = 40, and the separate argument 10 makes 50. 40 forgets the extra argument, 35 adds only A2 and A3, and 10 is just the last argument. - How many cells are there in the range C2:E6?
A) 20
B) 10
C) 12
D) 15
Answer: D) 15 — C2:E6 covers three columns (C, D, E) and five rows (2 to 6), so 3 × 5 = 15 cells. 12 and 20 come from miscounting the rows, and 10 comes from multiplying 2 × 5 using the difference between the column letters instead of the count. - What does =ROUND(48.736, 1) return?
A) 48.8
B) 49
C) 48.74
D) 48.7
Answer: D) 48.7 — One decimal place keeps the 7 and looks at the next digit, 3, which is below 5, so the value rounds down to 48.7. 48.8 would need the next digit to be 5 or more, 48.74 is rounding to two decimal places, and 49 is rounding to zero decimal places. - What value does Excel give for the formula =20-8/4×2 (× typed as the asterisk)?
A) 19
B) 12
C) 16
D) 6
Answer: C) 16 — Division and multiplication are done first from left to right: 8 ÷ 4 = 2 and 2 × 2 = 4, then 20 − 4 = 16. 6 comes from subtracting first, 19 from multiplying 4 × 2 before dividing, and 12 from ignoring the last two operations. - Sana’s sheet has 6 in A1, the number 0 in A2, nothing in A3 and 12 in A4. What does =AVERAGE(A1:A4) give?
A) 6
B) 18
C) 4.5
D) 9
Answer: A) 6 — AVERAGE ignores the blank cell but counts 0 as a number, so it divides 6 + 0 + 12 = 18 by 3 to get 6. 4.5 wrongly divides by 4 cells, 9 wrongly leaves out the zero, and 18 is only the total. - Kamran’s formula =B2/C2 shows an error because C2 is empty. Which error value appears?
A) #DIV/0!
B) #REF!
C) #N/A
D) #NAME?
Answer: A) #DIV/0! — An empty cell is treated as zero in division, so Excel shows #DIV/0!. #N/A means a looked-up value is missing, #NAME? means an unrecognised function or name, and #REF! means a reference to a deleted or invalid cell. - Deepa types =SUMM(B2:B9) instead of =SUM(B2:B9). What does the cell show?
A) #DIV/0!
B) #VALUE!
C) #NAME?
D) The correct total
Answer: C) #NAME? — Excel does not recognise the function name SUMM, so it returns #NAME?. #VALUE! is for arguments of the wrong type, #DIV/0! for division by zero, and Excel never silently corrects a misspelt function to give the total. - Zubair has the hours studied and the marks obtained by 30 students and wants to see whether more study goes with higher marks. Which chart should he use?
A) Scatter (XY) chart
B) Doughnut chart
C) Stacked column chart
D) Pie chart
Answer: A) Scatter (XY) chart — A scatter chart plots each student as a point using two numeric values, so a pattern between hours and marks becomes visible. Pie and doughnut charts show parts of one whole, and a stacked column chart compares category totals made of parts, not the link between two variables. - Cell B2 contains exactly 40. What does =IF(B2 ≥ 40, "Pass", "Fail") show? (Here ≥ stands for Excel’s greater-than-or-equal operator.)
A) TRUE
B) Pass
C) 40
D) Fail
Answer: B) Pass — The test 40 ≥ 40 is true, so IF returns its second argument, Pass. Fail would appear only for a value below 40. IF returns the given results rather than the word TRUE or the cell’s own value. - Cell C2 contains =IF(B2 ≥ 80, "A", IF(B2 ≥ 60, "B", "C")) and B2 holds 80. What is the result? (Here ≥ stands for Excel’s greater-than-or-equal operator.)
A) #VALUE!
B) C
C) A
D) B
Answer: C) A — The first test 80 ≥ 80 is true, so Excel returns A and does not look at the inner IF. B would need a value from 60 up to 79, C a value below 60, and there is no type problem that could cause #VALUE!. - Range A2:C5 holds IDs 201, 202, 203, 204 in column A, names Ayesha, Ravi, Sana, Arjun in column B and marks 78, 91, 66, 85 in column C. What does =VLOOKUP(203, A2:C5, 3, FALSE) return?
A) Sana
B) 203
C) 85
D) 66
Answer: D) 66 — VLOOKUP finds 203 in the first column, in the row of Sana, and returns column 3 of that row, which holds the mark 66. Sana is in column 2, 203 is column 1 itself, and 85 belongs to ID 204. - Cell D2 contains a formula that refers to A1 with only the column locked (a dollar sign before A, none before 1). The formula is copied to F5. Which cell does the copied formula refer to?
A) A1
B) A4
C) C4
D) C1
Answer: B) A4 — Moving from D2 to F5 is 2 columns right and 3 rows down. The locked column stays A and the free row changes from 1 to 4, giving A4. C4 would need the column to move too, A1 would need both parts locked, and C1 is what you get with only the row locked. - B2 to B4 contain 200, 350 and 500, and F1 contains 0.1. C2 holds =B2×F1 with F1 fully locked (dollar signs before F and before 1). After C2 is copied to C3 and C4, what does C4 show?
A) 0
B) 50
C) 20
D) 35
Answer: B) 50 — The copy in C4 is =B4×F1 because B moves down while F1 stays fixed, so 500 × 0.1 = 50. 0 is what an unlocked F1 would give, since the reference would slide to the empty F3. 35 is the result in C3 and 20 the result in C2.
Questions
What is the difference between a formula and a function in Excel?
A formula is anything you type that starts with an equals sign and calculates a result, such as =B2+C2. A function is a ready-made named calculation, such as SUM or VLOOKUP, that you can use inside a formula.
When should I use an absolute reference?
Whenever every copy of a formula must use the same single cell, such as a tax rate, a unit price or a grand total. Lock both its column and row with dollar signs, or press F4 while the reference is selected.
Why does VLOOKUP return #N/A?
With FALSE as the last argument it needs an exact match, so #N/A means the lookup value is not in the first column of the range. Common causes are a spelling difference, an extra space, or numbers stored as text.
Does AVERAGE count blank cells as zero?
No. Blank cells and text are ignored, so they do not reduce the average. A cell that actually contains 0 is counted.