Sub topic 2
Anatomy of a function call
This chapter assumes you can enter values in cells, select ranges with the mouse or keyboard, and know that a formula starts with an equals sign. It covers how an Excel function call is built, so that SUM, AVERAGE, MIN, MAX, and COUNT read the same way in every later chapter.
The parts of a call
A function call has four parts: the equals sign, the function name, a pair of parentheses, and the arguments inside the parentheses. Arguments are separated by commas.
=SUM(B2:B6, D2:D6, 100)In this formula:
=tells Excel to calculate instead of storing text.SUMis the function name. Excel accepts it in any letter case and shows it in capitals.( )enclose the arguments. The opening and closing parenthesis are both required.B2:B6,D2:D6, and100are three arguments, separated by commas.
Some locales use a semicolon as the argument separator. If your copy of Excel rejects a comma, try a semicolon.
What counts as an argument
An argument can be any of these:
| Argument type | Example | Meaning |
|---|---|---|
| Single cell | `B2` | The value in one cell |
| Range | `B2:B6` | Every cell from B2 down to B6 |
| Constant | `100` | A number typed into the formula |
| Another formula or function | `AVERAGE(D2:D6)` | The result of a nested calculation |
A range is written as the first cell, a colon, and the last cell. Functions read the values in the range, so =SUM(B2:B6) adds five cells and returns one number.
Required and optional arguments
Each function needs at least one argument. SUM, AVERAGE, MIN, MAX, and COUNT all accept up to 255 arguments, and each argument can itself be a large range. You do not need to pass a single range. These two formulas give the same result:
=SUM(B2:B4, B5:B6)
=SUM(B2:B6)Functions that take a list of arguments treat them as one pool of values. They do not care where the values came from.
Nesting and the result type
A function call can sit inside another call. Excel evaluates the inner call first and passes its result to the outer one.
=MAX(B2:B6) - MIN(B2:B6)
=ROUND(AVERAGE(B2:B6), 1)The first line subtracts one result from another. In the second line, ROUND receives two arguments: the average and the number of decimal places. The comma separates the two arguments of ROUND, not of AVERAGE.
Common mistakes
Most syntax problems fall into a few patterns.
- Missing parenthesis.
=SUM(B2:B6is incomplete. Excel often offers to fix it, but check that it closes where you intended. - Wrong separator. Using
B2:B6 D2:D6(a space) does not make two arguments. A space is an intersection operator and usually returns#NULL!. - Typed name wrong.
=SUMM(B2:B6)returns#NAME?, because Excel does not recognize the function. - Numbers stored as text. A value that looks like a number but is stored as text is skipped by these functions. The chapter on data types covers this.
Reading a formula you did not write
Work from the outside in. Identify the outermost function, count its arguments by finding the commas at the top level, and then read each argument on its own. Commas inside a nested call's parentheses belong to that nested call.
Exercise
In =ROUND(AVERAGE(B2:B6, D2:D6), 1), how many arguments does AVERAGE receive, and how many does ROUND receive?
Show answer
AVERAGE receives two arguments (the ranges B2:B6 and D2:D6). ROUND receives two arguments: the result of AVERAGE and the number 1. The comma between the two ranges is inside AVERAGE's parentheses, so it belongs to AVERAGE.
Exercise
What error does =SUMM(B2:B6) return, and why?
Show answer
It returns #NAME?, because SUMM is not a function name Excel recognizes.